-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJ01013.java
More file actions
36 lines (33 loc) · 906 Bytes
/
J01013.java
File metadata and controls
36 lines (33 loc) · 906 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package CODE_PTIT;
import java.util.Scanner;
public class J01013 {
static int a[] = new int[2000001];
public static void Process() {
for (int i = 2; i * i <= 2000000; i++){
if (a[i] == 0){
for (int j = i * i; j <= 2000000; j += i){
a[j] = i;
}
}
}
for(int i = 2; i <= 2000000; i++){
if (a[i] == 0){
a[i] = i;
}
}
}
public static void main(String[] args) {
Scanner inp = new Scanner(System.in);
Process();
long s = 0;
int t = inp.nextInt();
while (t-- > 0) {
int n = inp.nextInt();
while (n != 1) {
s += a[n];
n /= a[n];
}
}
System.out.print(s);
}
}