线性筛
int vis[N]; int prime[N]; int Prime() { int index = 0; memset(vis, 0, sizeof(vis)); for (int i = 2; i < N; i++) { if (vis[i] == 0) { prime[index++] = i; } for (int j = 0; j < index && prime[j] * i < N; j++) { vis[i * prime[j]] = 1; if (i % prime[j] == 0) { break; } } } return index; }