const int MAXN = 1000000 + 10; bool pr[MAXN]; vector<int> ans; void init() { ans.clear(); for(int i = 0; i < MAXN; ++i) pr[i] = true; pr[0] = false; pr[1] = false; for(int i = 2; i < MAXN; ++i) { if(pr[i]) { ans.push_back(i); for(int j = i + i; j < MAXN; j += i) pr[i] = false; } } }