-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path146.cpp
More file actions
86 lines (86 loc) · 1.95 KB
/
Copy path146.cpp
File metadata and controls
86 lines (86 loc) · 1.95 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <functional>
#define ll long long
using namespace std;
const int mx = 150 * (int)1e6;
bool is_prime[mx];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
for (int i = 0; i < mx; i++) {
is_prime[i] = true;
}
vector<int> primes;
for (int i = 2; i < mx; i++) {
if (is_prime[i]) {
for (int j = 2 * i; j < mx; j += i) {
is_prime[j] = false;
}
primes.push_back(i);
}
}
//cout << primes.size() << endl;
//exit(0);
ll offset[] = {1, 3, 7, 9, 13, 27};
vector<ll> pos;
for (ll n = 10; n <= mx; n++) {
bool fine = true;
for (ll p: primes) {
for (ll x: offset) {
if ((n * n + x) % p == 0 and p != n * n + x) {
fine = false;
break;
}
}
if (!fine) {
break;
}
}
if (!fine) {
continue;
}
//pos.push_back(n);
for (int x = 1; x < 27; x += 2) {
if (x == 1 or x == 3 or x == 9 or x == 7 or x == 27 or x == 13) continue;
bool found = false;
for (int p: primes) {
if ((n * n + x) % p == 0 and p != n * n + x) {
found = true;
break;
}
}
if (!found) {
fine = false;
break;
}
}
if (!fine) {
//pos.push_back(n);
continue;
}
pos.push_back(n);
}
cout << "SIZE :" << pos.size() << endl;
ll sum = 0;
for (ll x: pos) {
cout << x << " ";
sum += x;
}
cout << endl;
cout << "SUM " << sum;
exit(0);
for (int i: pos) {
cout << i << ' ';
}
cout << endl;
}
//n^2 + 3 must be n^2^(1/3)