Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
128792 林嘉乐 素数检测 C++ Accepted 62 MS 3184 KB 298 2025-08-19 17:21:27

Tests(1/1):


Code:

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