結果

問題 No.278 連続する整数の和(2)
ユーザー nanophoto12
提出日時 2015-09-13 17:36:56
言語 Java
(openjdk 23)
結果
AC  
実行時間 159 ms / 2,000 ms
コード長 642 bytes
コンパイル時間 2,151 ms
コンパイル使用メモリ 74,640 KB
実行使用メモリ 45,712 KB
最終ジャッジ日時 2024-12-23 09:07:18
合計ジャッジ時間 5,433 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

package com.company;

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        Long value = scanner.nextLong();
        if(value % 2 == 0)
        {
            value /=2;
        }
        Long sum = 0L;
        for(Long i = 1L; i * i <= value;i++)
        {
            if(value % i == 0)
            {
                Long other = value / i;
                sum += i;
                if(i < other)
                {
                    sum += other;
                }
            }
        }

        System.out.println(sum.toString());
    }
}
0