結果

問題 No.278 連続する整数の和(2)
ユーザー GrenacheGrenache
提出日時 2015-09-05 09:21:17
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 601 bytes
コンパイル時間 3,192 ms
コンパイル使用メモリ 72,308 KB
実行使用メモリ 56,316 KB
最終ジャッジ日時 2023-09-26 08:44:59
合計ジャッジ時間 6,661 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
56,016 KB
testcase_01 AC 122 ms
55,992 KB
testcase_02 AC 136 ms
56,140 KB
testcase_03 AC 120 ms
55,776 KB
testcase_04 AC 120 ms
56,276 KB
testcase_05 AC 120 ms
55,672 KB
testcase_06 AC 123 ms
55,940 KB
testcase_07 AC 121 ms
55,992 KB
testcase_08 WA -
testcase_09 AC 137 ms
56,192 KB
testcase_10 AC 139 ms
56,316 KB
testcase_11 AC 139 ms
55,876 KB
testcase_12 AC 121 ms
56,192 KB
testcase_13 AC 138 ms
56,180 KB
testcase_14 AC 133 ms
56,080 KB
testcase_15 AC 132 ms
55,748 KB
testcase_16 AC 130 ms
55,560 KB
testcase_17 AC 136 ms
55,652 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;
        			ret += n / j;
        		}
        	}
		
        	System.out.println(ret);
        } else {
        	System.out.println("1");
        }
		
		sc.close();
    }
}
0