Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
129058 | 刘子隽bylz | 求素数 | C++ | 运行出错 | 0 | 1 MS | 340 KB | 292 | 2024-01-26 16:03:24 |
#include<bits/stdc++.h> using namespace std; int main() { bool a[100000]{0}; long long n=100000; for (int i=2;i<sqrt(n);i++){ if (!a[i]){ for(int j=2;i*j<=n;j++) a[i*j]=1; } } for(int i=2;i<=n;i++){ if(!a[i]) cout<<i<<" "; } cout<<endl; }