Skip to content

Commit 21c7df9

Browse files
authored
Merge pull request #1842 from AlgorithmWithGod/Ukj0ng
[20260127] BOJ / G4 / 약수의 합 / 한종욱
2 parents 2e9ec6e + ef34ceb commit 21c7df9

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
```
2+
import java.io.*;
3+
import java.util.*;
4+
5+
public class Main {
6+
private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
7+
private static final BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
8+
private static final int MAX = 1000000;
9+
private static long[] f, g;
10+
private static int N;
11+
12+
public static void main(String[] args) throws IOException {
13+
int T = Integer.parseInt(br.readLine());
14+
f = new long[MAX+1];
15+
g = new long[MAX+1];
16+
17+
Arrays.fill(f, 1);
18+
19+
for (int i = 2; i <= MAX; i++) {
20+
for (int j = 1; i*j <= MAX; j++) {
21+
f[i*j] += i;
22+
}
23+
}
24+
25+
for (int i = 1; i <= MAX; i++) {
26+
g[i] = g[i-1]+f[i];
27+
}
28+
29+
while (T-->0) {
30+
init();
31+
bw.write(g[N] + "\n");
32+
}
33+
34+
bw.flush();
35+
bw.close();
36+
br.close();
37+
}
38+
39+
private static void init() throws IOException {
40+
N = Integer.parseInt(br.readLine());
41+
}
42+
}
43+
```

0 commit comments

Comments
 (0)