結果

問題 No.278 連続する整数の和(2)
ユーザー htensaihtensai
提出日時 2020-01-09 11:39:37
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 704 bytes
コンパイル時間 2,056 ms
コンパイル使用メモリ 71,076 KB
実行使用メモリ 51,396 KB
最終ジャッジ日時 2023-08-15 01:11:43
合計ジャッジ時間 4,169 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
49,532 KB
testcase_01 WA -
testcase_02 AC 63 ms
50,156 KB
testcase_03 AC 42 ms
49,324 KB
testcase_04 AC 42 ms
49,260 KB
testcase_05 AC 43 ms
49,332 KB
testcase_06 AC 44 ms
49,544 KB
testcase_07 AC 42 ms
49,672 KB
testcase_08 AC 62 ms
50,052 KB
testcase_09 AC 62 ms
50,080 KB
testcase_10 AC 67 ms
50,096 KB
testcase_11 AC 63 ms
49,912 KB
testcase_12 WA -
testcase_13 AC 62 ms
50,084 KB
testcase_14 AC 57 ms
49,996 KB
testcase_15 AC 59 ms
50,392 KB
testcase_16 AC 56 ms
51,396 KB
testcase_17 AC 61 ms
50,092 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        long n = Long.parseLong(br.readLine());
        long g;
        if (n % 2 == 0) {
            g = n / 2;
        } else {
            g = n;
        }
        long ans = 1 + g;
        for (long i = 2; i <= Math.sqrt(g); i++) {
            if (g % i == 0) {
                if (i * i == g) {
                    ans += i;
                } else {
                    ans += i;
                    ans += g / i;
                }
            }
        }
        System.out.println(ans);
    }
}
0