Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
96049 孙嘉言 素数检测 C++ Accepted 48 MS 3192 KB 330 2024-11-02 17:49:29

Tests(1/1):


Code:

#include <iostream> #include <cstring> #include <cmath> using namespace std; const long long n=3000000; bool isPrimes[n+1]={0}; int main(){ for(int i=2;i*i<=n;i++){ if(isPrimes[i]) continue; for(int j=i*i;j<=n;j+=i) isPrimes[j]=1; } for(int i=2;i<=n;i++){ if(!isPrimes[i]) cout<<i<<' '; } return 0; }