結果

問題 No.888 約数の総和
ユーザー tentententen
提出日時 2022-09-13 17:31:48
言語 Java21
(openjdk 21)
結果
AC  
実行時間 70 ms / 2,000 ms
コード長 1,210 bytes
コンパイル時間 2,333 ms
コンパイル使用メモリ 77,496 KB
実行使用メモリ 37,996 KB
最終ジャッジ日時 2024-05-08 01:41:18
合計ジャッジ時間 4,790 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
36,940 KB
testcase_01 AC 47 ms
37,140 KB
testcase_02 AC 47 ms
37,052 KB
testcase_03 AC 49 ms
36,972 KB
testcase_04 AC 46 ms
36,776 KB
testcase_05 AC 46 ms
37,232 KB
testcase_06 AC 46 ms
37,076 KB
testcase_07 AC 46 ms
37,280 KB
testcase_08 AC 48 ms
36,896 KB
testcase_09 AC 48 ms
37,052 KB
testcase_10 AC 47 ms
37,100 KB
testcase_11 AC 47 ms
36,748 KB
testcase_12 AC 48 ms
36,980 KB
testcase_13 AC 48 ms
36,820 KB
testcase_14 AC 46 ms
37,188 KB
testcase_15 AC 49 ms
36,648 KB
testcase_16 AC 46 ms
36,984 KB
testcase_17 AC 46 ms
37,192 KB
testcase_18 AC 67 ms
37,896 KB
testcase_19 AC 64 ms
37,888 KB
testcase_20 AC 65 ms
37,792 KB
testcase_21 AC 70 ms
37,864 KB
testcase_22 AC 67 ms
37,868 KB
testcase_23 AC 50 ms
37,192 KB
testcase_24 AC 62 ms
37,996 KB
testcase_25 AC 62 ms
37,940 KB
testcase_26 AC 62 ms
37,780 KB
testcase_27 AC 63 ms
37,868 KB
testcase_28 AC 65 ms
37,752 KB
testcase_29 AC 65 ms
37,720 KB
testcase_30 AC 67 ms
37,864 KB
testcase_31 AC 69 ms
37,904 KB
testcase_32 AC 67 ms
37,800 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