Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
42419 | 纪哲弘 | 素数检测 | C++ | Accepted | 48 MS | 3184 KB | 343 | 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 << ' '; } } }