Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
47532 | 张俊杰 | 素数检测 | C++ | Accepted | 43 MS | 3180 KB | 453 | 2023-05-02 17:59:37 |
#include<iostream> #include<cstdio> #include<cmath> #include<cstring> 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]==0){ cout<<i<<" "; } } return 0; }