Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
59480 孙诗皓 素数检测 C++ Accepted 57 MS 11972 KB 349 2023-10-28 16:20:37

Tests(1/1):


Code:

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