結果

問題 No.1737 One to N
ユーザー AsahiAsahi
提出日時 2023-02-06 13:57:49
言語 Java21
(openjdk 21)
結果
AC  
実行時間 145 ms / 2,000 ms
コード長 1,012 bytes
コンパイル時間 3,150 ms
コンパイル使用メモリ 73,684 KB
実行使用メモリ 55,976 KB
最終ジャッジ日時 2023-09-18 01:31:47
合計ジャッジ時間 9,094 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
55,928 KB
testcase_01 AC 130 ms
55,832 KB
testcase_02 AC 128 ms
55,572 KB
testcase_03 AC 127 ms
55,392 KB
testcase_04 AC 126 ms
55,864 KB
testcase_05 AC 130 ms
55,672 KB
testcase_06 AC 129 ms
55,668 KB
testcase_07 AC 128 ms
55,852 KB
testcase_08 AC 139 ms
55,624 KB
testcase_09 AC 132 ms
55,704 KB
testcase_10 AC 135 ms
55,976 KB
testcase_11 AC 145 ms
55,412 KB
testcase_12 AC 140 ms
55,492 KB
testcase_13 AC 137 ms
55,712 KB
testcase_14 AC 127 ms
55,556 KB
testcase_15 AC 128 ms
55,312 KB
testcase_16 AC 129 ms
55,564 KB
testcase_17 AC 127 ms
55,568 KB
testcase_18 AC 126 ms
55,600 KB
testcase_19 AC 131 ms
55,644 KB
testcase_20 AC 127 ms
55,480 KB
testcase_21 AC 129 ms
55,680 KB
testcase_22 AC 137 ms
55,944 KB
testcase_23 AC 129 ms
55,480 KB
testcase_24 AC 129 ms
55,604 KB
testcase_25 AC 127 ms
55,664 KB
testcase_26 AC 130 ms
55,328 KB
testcase_27 AC 128 ms
55,740 KB
testcase_28 AC 125 ms
55,612 KB
testcase_29 AC 125 ms
55,852 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;
import java.math.*;
// import java.util.stream.Stream;

class Main{
    static BufferedReader buff = new BufferedReader(new InputStreamReader(System.in));
    static StringTokenizer st;
    static PrintWriter output = new PrintWriter(System.out);
    static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws IOException{
        long n = sc.nextLong();
        Map<Long,Integer> m = prime_factorization(n);
        long ans = 0;
        for(long val : m.keySet()) ans += val*m.get(val);
        output.print(ans);
        output.flush();
    }
    static Map<Long,Integer> prime_factorization(long val) {
        Map<Long,Integer> map = new HashMap<>();
        for(long i=2; i*i<=val;i++) {
            int count = 0;
            while(val % i == 0) {
                val /= i;
                count++;
            }
            if(count > 0)map.put(i,count);
        }
        if(val != 1L) map.put(val,1);
        return map;
    }
}
0