結果

問題 No.888 約数の総和
ユーザー tentententen
提出日時 2022-09-13 17:31:48
言語 Java21
(openjdk 21)
結果
AC  
実行時間 65 ms / 2,000 ms
コード長 1,210 bytes
コンパイル時間 2,106 ms
コンパイル使用メモリ 73,620 KB
実行使用メモリ 51,020 KB
最終ジャッジ日時 2023-08-20 19:15:13
合計ジャッジ時間 5,456 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
49,532 KB
testcase_01 AC 46 ms
49,348 KB
testcase_02 AC 44 ms
49,288 KB
testcase_03 AC 45 ms
49,180 KB
testcase_04 AC 45 ms
49,256 KB
testcase_05 AC 46 ms
49,132 KB
testcase_06 AC 45 ms
49,132 KB
testcase_07 AC 45 ms
49,644 KB
testcase_08 AC 45 ms
49,184 KB
testcase_09 AC 44 ms
49,120 KB
testcase_10 AC 44 ms
49,188 KB
testcase_11 AC 44 ms
49,352 KB
testcase_12 AC 44 ms
49,372 KB
testcase_13 AC 44 ms
49,248 KB
testcase_14 AC 44 ms
49,020 KB
testcase_15 AC 44 ms
49,140 KB
testcase_16 AC 44 ms
49,352 KB
testcase_17 AC 45 ms
49,028 KB
testcase_18 AC 63 ms
49,660 KB
testcase_19 AC 60 ms
49,740 KB
testcase_20 AC 58 ms
49,568 KB
testcase_21 AC 64 ms
50,592 KB
testcase_22 AC 64 ms
49,628 KB
testcase_23 AC 47 ms
51,020 KB
testcase_24 AC 57 ms
49,628 KB
testcase_25 AC 58 ms
49,904 KB
testcase_26 AC 58 ms
49,536 KB
testcase_27 AC 60 ms
49,684 KB
testcase_28 AC 62 ms
49,980 KB
testcase_29 AC 64 ms
49,744 KB
testcase_30 AC 62 ms
49,956 KB
testcase_31 AC 63 ms
48,868 KB
testcase_32 AC 65 ms
50,028 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        long n = sc.nextLong();
        long ans = 0;
        for (long i = 1; i <= Math.sqrt(n); i++) {
            if (n % i == 0) {
                ans += i;
                if (n > i * i) {
                    ans += n / i;
                }
            }
        }
        System.out.println(ans);
    }
}
    
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    
}
0