結果

問題 No.278 連続する整数の和(2)
ユーザー ぴろずぴろず
提出日時 2015-09-04 22:41:58
言語 Java21
(openjdk 21)
結果
AC  
実行時間 144 ms / 2,000 ms
コード長 487 bytes
コンパイル時間 3,712 ms
コンパイル使用メモリ 74,436 KB
実行使用メモリ 58,124 KB
最終ジャッジ日時 2023-08-24 22:35:19
合計ジャッジ時間 7,116 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
55,960 KB
testcase_01 AC 121 ms
55,788 KB
testcase_02 AC 137 ms
56,004 KB
testcase_03 AC 120 ms
55,668 KB
testcase_04 AC 119 ms
55,324 KB
testcase_05 AC 124 ms
55,828 KB
testcase_06 AC 122 ms
55,708 KB
testcase_07 AC 127 ms
55,608 KB
testcase_08 AC 141 ms
58,124 KB
testcase_09 AC 137 ms
55,672 KB
testcase_10 AC 144 ms
55,576 KB
testcase_11 AC 141 ms
55,724 KB
testcase_12 AC 125 ms
55,380 KB
testcase_13 AC 138 ms
56,316 KB
testcase_14 AC 139 ms
56,024 KB
testcase_15 AC 136 ms
55,604 KB
testcase_16 AC 135 ms
55,396 KB
testcase_17 AC 140 ms
55,884 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