Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- #define ll long long
- #define ld long double
- #define pb push_back
- #define x first
- #define y second
- #define fastread ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
- #define PI (atan(1)*4)
- #define mp make_pair
- using namespace std;
- const int maxn = 1e9+2, lim = sqrt(maxn);
- bitset<maxn> p(0);
- inline void sieve() {
- p.set();
- p[1] = 0;
- for (register int i = 4; i < maxn; i += 2)
- p[i] = 0;
- for (register int i = 3; i <= lim; i += 2) {
- if (p[i]) {
- int st = i * i, add = 2 * i;
- for (register int j = st; j < maxn; j += add)
- p[j] = 0;
- }
- }
- }
- int main()
- {
- fastread;
- sieve();
- vector<int> losing;
- losing.pb(0);
- losing.pb(3);
- int lim=maxn-1;
- for(register int i=4;i<lim;i++){
- int win=0;
- for(auto u:losing){
- if(p[i-u+1]){
- win=1;
- break;
- }
- }
- if(win==0)
- losing.pb(i);
- }
- for(auto u:losing)
- cout<<u<<",";
- return 0;
- }
Add Comment
Please, Sign In to add comment