File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed
Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change 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+ ```
You can’t perform that action at this time.
0 commit comments