4fd800b3a8 2011-02-23 kinaba: static const int N = 999999; 4fd800b3a8 2011-02-23 kinaba: vector<bool> isp(N+1, true); 4fd800b3a8 2011-02-23 kinaba: vector<int> ps; 4fd800b3a8 2011-02-23 kinaba: for(int p=2; p<=N; ++p) 4fd800b3a8 2011-02-23 kinaba: if( isp[p] ) { 4fd800b3a8 2011-02-23 kinaba: ps.push_back(p); 4fd800b3a8 2011-02-23 kinaba: for(int q=p+p; q<=N; q+=p) 4fd800b3a8 2011-02-23 kinaba: isp[q] = false; 4fd800b3a8 2011-02-23 kinaba: }