結果

問題 No.888 約数の総和
コンテスト
ユーザー neko_the_shadow
提出日時 2019-09-27 21:34:28
言語 Java
(openjdk 23)
結果
RE  
実行時間 -
コード長 564 bytes
コンパイル時間 2,304 ms
コンパイル使用メモリ 78,824 KB
実行使用メモリ 54,668 KB
最終ジャッジ日時 2024-09-24 20:54:35
合計ジャッジ時間 7,621 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 15 WA * 1 RE * 14
権限があれば一括ダウンロードができます

ソースコード

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);
        int n = stdin.nextInt();
        
        Set<Integer> facts = new HashSet<>();
        for (int fact = 1; fact * fact <= n; fact++) {
            if (n % fact != 0) continue;
            facts.add(fact);
            facts.add(n / fact);
        }
        
        int ans = facts.stream().mapToInt(Integer::intValue).sum();
        System.out.println(ans);
    }

}
0