Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
67413 冯诚阳 素数检测 C++ Accepted 59 MS 11980 KB 370 2024-03-16 14:56:41

Tests(1/1):


Code:

#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; }