📅  最后修改于: 2022-03-11 14:55:26.853000             🧑  作者: Mango
const int N = 10000000;
int lp[N+1];
vector pr;
for (int i=2; i<=N; ++i) {
if (lp[i] == 0) {
lp[i] = i;
pr.push_back (i);
}
for (int j=0; j<(int)pr.size() && pr[j]<=lp[i] && i*pr[j]<=N; ++j)
lp[i * pr[j]] = pr[j];
}