結果

問題 No.278 連続する整数の和(2)
ユーザー ぴろずぴろず
提出日時 2015-09-04 22:41:58
言語 Java17
(openjdk 17.0.1)
結果
AC  
実行時間 121 ms / 2,000 ms
コード長 487 bytes
コンパイル時間 2,682 ms
使用メモリ 37,992 KB
最終ジャッジ日時 2023-01-12 15:45:36
合計ジャッジ時間 5,884 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 94 ms
37,456 KB
testcase_01 AC 96 ms
37,488 KB
testcase_02 AC 117 ms
37,888 KB
testcase_03 AC 103 ms
37,524 KB
testcase_04 AC 96 ms
37,400 KB
testcase_05 AC 99 ms
37,400 KB
testcase_06 AC 98 ms
37,508 KB
testcase_07 AC 94 ms
37,488 KB
testcase_08 AC 119 ms
37,824 KB
testcase_09 AC 119 ms
37,992 KB
testcase_10 AC 121 ms
37,716 KB
testcase_11 AC 116 ms
37,712 KB
testcase_12 AC 93 ms
37,400 KB
testcase_13 AC 114 ms
37,804 KB
testcase_14 AC 114 ms
37,696 KB
testcase_15 AC 112 ms
37,836 KB
testcase_16 AC 110 ms
37,568 KB
testcase_17 AC 116 ms
37,844 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package no278;

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long m = n % 2 == 0 ? n / 2 : n;
		long ans = 0;
		for(long i=1;i*i<=m;i++) {
			if (m % i == 0) {
				ans += i;
				if (i * i != m) {
					ans += m / i;
				}
			}
		}
		System.out.println(ans);
	}
	public static long gcd(long a,long b) {
		while(b!=0) {
			long r = a%b;
			a = b;
			b = r;
		}
		return a;
	}
}
0