結果

問題 No.278 連続する整数の和(2)
ユーザー nanophoto12nanophoto12
提出日時 2015-09-13 17:36:56
言語 Java17
(openjdk 17.0.1)
結果
AC  
実行時間 146 ms / 2,000 ms
コード長 642 bytes
コンパイル時間 1,995 ms
使用メモリ 42,304 KB
最終ジャッジ日時 2023-01-12 15:55:49
合計ジャッジ時間 5,127 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 97 ms
37,360 KB
testcase_01 AC 97 ms
37,368 KB
testcase_02 AC 142 ms
42,056 KB
testcase_03 AC 93 ms
37,324 KB
testcase_04 AC 93 ms
37,472 KB
testcase_05 AC 102 ms
38,000 KB
testcase_06 AC 109 ms
38,256 KB
testcase_07 AC 106 ms
38,304 KB
testcase_08 AC 141 ms
42,224 KB
testcase_09 AC 146 ms
42,120 KB
testcase_10 AC 145 ms
42,056 KB
testcase_11 AC 140 ms
42,208 KB
testcase_12 AC 98 ms
37,392 KB
testcase_13 AC 146 ms
42,304 KB
testcase_14 AC 131 ms
42,072 KB
testcase_15 AC 136 ms
42,000 KB
testcase_16 AC 130 ms
42,096 KB
testcase_17 AC 141 ms
41,900 KB
権限があれば一括ダウンロードができます

ソースコード

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