結果

問題 No.278 連続する整数の和(2)
ユーザー GrenacheGrenache
提出日時 2015-09-05 09:24:19
言語 Java21
(openjdk 21)
結果
AC  
実行時間 140 ms / 2,000 ms
コード長 644 bytes
コンパイル時間 3,943 ms
コンパイル使用メモリ 72,348 KB
実行使用メモリ 56,268 KB
最終ジャッジ日時 2023-08-24 22:40:53
合計ジャッジ時間 6,268 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
55,544 KB
testcase_01 AC 121 ms
56,060 KB
testcase_02 AC 140 ms
55,984 KB
testcase_03 AC 122 ms
56,064 KB
testcase_04 AC 122 ms
55,680 KB
testcase_05 AC 123 ms
56,140 KB
testcase_06 AC 123 ms
55,656 KB
testcase_07 AC 122 ms
53,612 KB
testcase_08 AC 138 ms
56,268 KB
testcase_09 AC 138 ms
56,124 KB
testcase_10 AC 140 ms
55,656 KB
testcase_11 AC 140 ms
56,132 KB
testcase_12 AC 122 ms
55,876 KB
testcase_13 AC 137 ms
55,624 KB
testcase_14 AC 133 ms
56,268 KB
testcase_15 AC 134 ms
56,116 KB
testcase_16 AC 132 ms
56,088 KB
testcase_17 AC 137 ms
56,020 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;


public class Main_yukicoder278_1 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        long n = sc.nextLong();

        if (n == 1) {
        } else if (n % 2 == 1) {
        } else {
        	n = n / 2;
        }

        if (n != 1) {
        	long ret = 0;
        	for (long j = 1; j * j <= n; j++) {
        		if (n % j == 0) {
        			ret += j;
        			if (j != n / j) {
        				ret += n / j;
        			}
        		}
        	}
		
        	System.out.println(ret);
        } else {
        	System.out.println("1");
        }
		
		sc.close();
    }
}
0