結果

問題 No.888 約数の総和
ユーザー tentententen
提出日時 2020-08-30 21:53:27
言語 Java21
(openjdk 21)
結果
AC  
実行時間 141 ms / 2,000 ms
コード長 483 bytes
コンパイル時間 2,018 ms
コンパイル使用メモリ 71,112 KB
実行使用メモリ 56,164 KB
最終ジャッジ日時 2023-08-09 18:41:19
合計ジャッジ時間 8,603 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 118 ms
55,808 KB
testcase_01 AC 117 ms
53,848 KB
testcase_02 AC 121 ms
55,628 KB
testcase_03 AC 121 ms
55,676 KB
testcase_04 AC 122 ms
55,500 KB
testcase_05 AC 117 ms
56,040 KB
testcase_06 AC 120 ms
55,952 KB
testcase_07 AC 120 ms
55,984 KB
testcase_08 AC 119 ms
55,776 KB
testcase_09 AC 120 ms
55,704 KB
testcase_10 AC 122 ms
55,888 KB
testcase_11 AC 119 ms
56,164 KB
testcase_12 AC 122 ms
55,588 KB
testcase_13 AC 121 ms
55,308 KB
testcase_14 AC 122 ms
55,616 KB
testcase_15 AC 119 ms
55,556 KB
testcase_16 AC 122 ms
56,132 KB
testcase_17 AC 123 ms
55,792 KB
testcase_18 AC 138 ms
55,808 KB
testcase_19 AC 135 ms
55,680 KB
testcase_20 AC 134 ms
55,996 KB
testcase_21 AC 134 ms
55,600 KB
testcase_22 AC 141 ms
55,636 KB
testcase_23 AC 123 ms
55,772 KB
testcase_24 AC 132 ms
55,828 KB
testcase_25 AC 130 ms
55,620 KB
testcase_26 AC 130 ms
55,384 KB
testcase_27 AC 134 ms
55,868 KB
testcase_28 AC 135 ms
55,888 KB
testcase_29 AC 138 ms
55,620 KB
testcase_30 AC 136 ms
55,908 KB
testcase_31 AC 136 ms
55,816 KB
testcase_32 AC 135 ms
55,656 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	public static void main (String[] args) {
    	Scanner sc = new Scanner(System.in);
    	long n = sc.nextLong();
    	if (n == 1) {
    	    System.out.println(1);
    	    return;
    	}
    	long ans = n + 1;
    	for (long i = 2; i <= Math.sqrt(n); i++) {
    	    if (n % i == 0) {
    	        ans += i;
    	        if (i * i < n) {
    	            ans += n / i;
    	        }
    	    }
    	}
    	System.out.println(ans);
    }
}
0