Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
59477 | 万正钰 | 素数检测 | C++ | Accepted | 55 MS | 11976 KB | 370 | 2023-10-28 16:16:55 |
#include<iostream> #include<cstring> #include<cmath> using namespace std; const long long n=3000000; int b[n+1]={0}; int main(){ for(int i=2;i*i<=3000000;i++){ if(b[i]) continue; for(int j=i*i;j<=n;j+=i) b[j]=1; } for(int i=2;i<=n;i++){ if(!b[i]) cout<<i<<" "; } return 0; }