結果

問題 No.888 約数の総和
ユーザー ks2mks2m
提出日時 2019-09-20 22:29:05
言語 Java19
(openjdk 21)
結果
AC  
実行時間 154 ms / 2,000 ms
コード長 587 bytes
コンパイル時間 2,367 ms
コンパイル使用メモリ 80,508 KB
実行使用メモリ 56,340 KB
最終ジャッジ日時 2023-10-12 20:00:26
合計ジャッジ時間 8,610 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
55,940 KB
testcase_01 AC 132 ms
56,028 KB
testcase_02 AC 130 ms
55,912 KB
testcase_03 AC 131 ms
55,868 KB
testcase_04 AC 130 ms
55,732 KB
testcase_05 AC 130 ms
56,028 KB
testcase_06 AC 130 ms
56,152 KB
testcase_07 AC 133 ms
55,608 KB
testcase_08 AC 130 ms
55,888 KB
testcase_09 AC 131 ms
53,872 KB
testcase_10 AC 132 ms
55,776 KB
testcase_11 AC 130 ms
56,064 KB
testcase_12 AC 130 ms
56,184 KB
testcase_13 AC 130 ms
55,908 KB
testcase_14 AC 133 ms
55,840 KB
testcase_15 AC 131 ms
55,940 KB
testcase_16 AC 131 ms
55,972 KB
testcase_17 AC 131 ms
55,960 KB
testcase_18 AC 151 ms
56,000 KB
testcase_19 AC 149 ms
56,084 KB
testcase_20 AC 147 ms
56,164 KB
testcase_21 AC 151 ms
56,012 KB
testcase_22 AC 150 ms
56,156 KB
testcase_23 AC 131 ms
56,004 KB
testcase_24 AC 141 ms
55,540 KB
testcase_25 AC 146 ms
56,164 KB
testcase_26 AC 147 ms
55,700 KB
testcase_27 AC 147 ms
55,840 KB
testcase_28 AC 145 ms
55,936 KB
testcase_29 AC 146 ms
55,924 KB
testcase_30 AC 146 ms
56,340 KB
testcase_31 AC 148 ms
55,956 KB
testcase_32 AC 154 ms
55,928 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		sc.close();

		List<Long> list = new ArrayList<>();
		long end = (long) Math.sqrt(n);
		for (int i = 1; i <= end; i++) {
			if (n % i == 0) {
				list.add((long) i);
			}
		}
		int i = end * end == n ? list.size() - 2 : list.size() - 1;
		for ( ; i >= 0; i--) {
			list.add(n / list.get(i));
		}

		System.out.println(list.stream().mapToLong(a -> a).sum());
	}
}
0