結果
| 問題 |
No.1737 One to N
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-02-06 13:57:49 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 128 ms / 2,000 ms |
| コード長 | 1,012 bytes |
| コンパイル時間 | 2,604 ms |
| コンパイル使用メモリ | 76,588 KB |
| 実行使用メモリ | 41,696 KB |
| 最終ジャッジ日時 | 2024-07-04 18:31:57 |
| 合計ジャッジ時間 | 6,501 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 |
ソースコード
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;
}
}