Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
114222 孙睿阳 素数检测 C++ Accepted 58 MS 11980 KB 324 2025-03-22 11:15:18

Tests(1/1):


Code:

#include<bits/stdc++.h> using namespace std; int a[3000001]; int main(){ for(int i=2;i<=3000000;i++){ if(a[i]==1){ continue; } for(int j=2*i;j<=3000000;j+=i){ a[j]=1; } if(i*i>3000000){ break; } } for(int i=2;i<=3000000;i++){ if(a[i]==0){ cout<<i<<" "; } } return 0; }