Run ID:42419
提交时间:2022-11-19 14:43:34
#include <iostream> using namespace std; const long long n = 3000000; bool isPrimes[n + 1] = {0}; int main() { for (int i = 2; i * i <= n; i++) { if (isPrimes[i]) continue; for (int j = i * i; j <= n; j += i) isPrimes[j] = 1; } for (int i = 2; i <= n; i++) { if (!isPrimes[i]) { cout << i << ' '; } } }