-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path12.cpp
61 lines (54 loc) · 1.15 KB
/
12.cpp
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 200000;
const int T = 2000000;
int a[N];
bool v[T];
int tot = 0;
long long ans = 0;
int main() {
memset(v, 1, sizeof(v));
v[1] = false;
for(int i = 2; i < T; i+=2) {
v[i] = false;
}
v[2] = true;
a[tot++] = 2;
for(int i = 3; i < T; i++) {
if(v[i]) {
a[tot++] = i;
for(int j = i * 2; j < T; j+=i) {
v[j] = false;
}
}
}
/*for(int i = 0; i < tot; i++) {
//cout << a[i] << endl;
ans += a[i];
}*/
//cout << ans << endl;
//
long long tr = 0;
int num = 1;
while(1){
tr += num;
int cnt = 1;
long long temp = tr;
int id = upper_bound(a, a + tot, tr) - a;
for(int i = id - 1; i >= 0; i--) {
int tt = 1;
while(temp % a[i] == 0) {
temp /= a[i];
tt ++;
}
cnt *= tt;
}
cout << tr << ' ' << cnt << endl;
num ++;
if(cnt > 500) break;
}
cout << tr << endl;
}