-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path361.cpp
More file actions
72 lines (61 loc) · 1.22 KB
/
Copy path361.cpp
File metadata and controls
72 lines (61 loc) · 1.22 KB
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
62
63
64
65
66
67
68
69
70
71
72
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 65536;
int num_prime = 0;
int isNotPrime[N] = {1, 1};
int prime[N];
unsigned long long list[70000];
bool cmp(unsigned long long a, unsigned long long b) {
return a < b;
}
int main() {
for(int i = 2 ; i < N ; i ++)
{
if(! isNotPrime[i]) {
prime[num_prime++] = i;
}
for(long j = 0 ; j < num_prime; j++)
{
if (1LL * i * prime[j] >= N ) {
break;
}
isNotPrime[i * prime[j]] = 1;
if( !(i % prime[j] ) )
break;
}
}
isNotPrime[0] = false;
isNotPrime[1] = false;
int count = 0;
for (int i = 2; i < 65536; ++ i) {
unsigned long long ans = 1LL;
unsigned long long a1 = 0LL, a2 = 1LL;
for (int j = 1; j < 64; ++ j) {
ans = ans * i;
a1 = a1 * i;
a2 = a2 * i;
if (a2 > 10000000000LL) {
a1 += a2/10000000000LL;
a2 = a2%10000000000LL;
}
if (isNotPrime[j]) {
if (a1 < 1844674407LL || (a1 == 1844674407LL && a2 < 3709551616LL)) {
list[count ++] = ans;
}
else {
break;
}
}
}
}
list[count++] = 1;
sort(list, list+count, cmp);
cout << list[0] << endl;
for (int i = 1; i < count; ++ i) {
if (list[i] != list[i-1]) {
cout << list[i] << endl;
}
}
return 0;
}