結果

問題 No.278 連続する整数の和(2)
ユーザー tentententen
提出日時 2020-10-05 09:41:11
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 556 bytes
コンパイル時間 2,096 ms
コンパイル使用メモリ 71,552 KB
実行使用メモリ 56,324 KB
最終ジャッジ日時 2023-09-27 01:47:24
合計ジャッジ時間 5,618 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
55,676 KB
testcase_01 WA -
testcase_02 AC 138 ms
55,636 KB
testcase_03 AC 120 ms
55,780 KB
testcase_04 AC 120 ms
55,844 KB
testcase_05 AC 120 ms
55,864 KB
testcase_06 AC 123 ms
55,716 KB
testcase_07 AC 122 ms
55,500 KB
testcase_08 AC 137 ms
55,920 KB
testcase_09 AC 137 ms
53,728 KB
testcase_10 AC 142 ms
55,784 KB
testcase_11 AC 139 ms
55,780 KB
testcase_12 WA -
testcase_13 AC 136 ms
55,804 KB
testcase_14 AC 131 ms
56,312 KB
testcase_15 AC 133 ms
55,220 KB
testcase_16 AC 130 ms
55,928 KB
testcase_17 AC 137 ms
55,808 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long x;
        if (n % 2 == 0) {
            x = n / 2;
        } else {
            x = n;
        }
        long ans = 1 + x;
        for (long i = 2; i <= Math.sqrt(x); i++) {
            if (x % i == 0) {
                ans += i;
                if (i * i < x) {
                    ans += x / i;
                }
            }
        }
        System.out.println(ans);
    }
}
0