Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
113967 | 石茂诤 | 素数检测 | C++ | Accepted | 54 MS | 12824 KB | 397 | 2025-03-18 13:26:15 |
#include <iostream> #include <cmath> using namespace std; int primes[3000000]; int st[3000000]; int main() { int i,j,n=3000000,cnt=0; // cin>>n; for(i = 2; i <n;i++) { if(!st[i]) primes[cnt++] = i; for(j=0;i*primes[j]<n;j++) { st[i*primes[j]] = 1; if(i%primes[j]==0) break; } } for(i = 0; i <cnt;i++) { cout<<primes[i]<<" "; } }