結果

問題 No.888 約数の総和
ユーザー neko_the_shadowneko_the_shadow
提出日時 2019-09-27 21:35:32
言語 Java21
(openjdk 21)
結果
AC  
実行時間 159 ms / 2,000 ms
コード長 564 bytes
コンパイル時間 2,519 ms
コンパイル使用メモリ 78,336 KB
実行使用メモリ 58,172 KB
最終ジャッジ日時 2023-10-25 02:00:35
合計ジャッジ時間 8,541 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 134 ms
57,688 KB
testcase_01 AC 135 ms
57,672 KB
testcase_02 AC 134 ms
57,756 KB
testcase_03 AC 134 ms
57,756 KB
testcase_04 AC 135 ms
57,624 KB
testcase_05 AC 135 ms
57,968 KB
testcase_06 AC 135 ms
57,716 KB
testcase_07 AC 134 ms
57,676 KB
testcase_08 AC 134 ms
57,416 KB
testcase_09 AC 134 ms
55,664 KB
testcase_10 AC 135 ms
57,684 KB
testcase_11 AC 136 ms
57,928 KB
testcase_12 AC 134 ms
57,680 KB
testcase_13 AC 135 ms
57,852 KB
testcase_14 AC 134 ms
57,348 KB
testcase_15 AC 135 ms
57,736 KB
testcase_16 AC 135 ms
57,888 KB
testcase_17 AC 134 ms
57,648 KB
testcase_18 AC 159 ms
57,688 KB
testcase_19 AC 153 ms
58,016 KB
testcase_20 AC 148 ms
58,144 KB
testcase_21 AC 159 ms
58,172 KB
testcase_22 AC 156 ms
57,828 KB
testcase_23 AC 134 ms
57,568 KB
testcase_24 AC 144 ms
55,792 KB
testcase_25 AC 150 ms
57,684 KB
testcase_26 AC 146 ms
57,888 KB
testcase_27 AC 149 ms
57,724 KB
testcase_28 AC 147 ms
57,784 KB
testcase_29 AC 150 ms
57,860 KB
testcase_30 AC 149 ms
57,748 KB
testcase_31 AC 150 ms
57,840 KB
testcase_32 AC 154 ms
55,784 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

    public static void main(String[] args) {
        Scanner stdin = new Scanner(System.in);
        long n = stdin.nextLong();
        
        Set<Long> facts = new HashSet<>();
        for (long fact = 1; fact * fact <= n; fact++) {
            if (n % fact != 0) continue;
            facts.add(fact);
            facts.add(n / fact);
        }
        
        long ans = facts.stream().mapToLong(Long::longValue).sum();
        System.out.println(ans);
    }

}
0