Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
155767 任艺宸 素数检测 C++ Accepted 50 MS 3192 KB 512 2026-06-13 12:02:25

Tests(1/1):


Code:

#include<iostream> // cin\cout\endl #include<cstdio> //scanf()\printf() #include<cstring> // strcpy()\strcat()\strcmp()\strlen()\memset() #include<cmath> //sqrt()\pow()\abs()\ceil()\floor()\max()\min() using namespace std; const long long n=3000000; int main(){ bool ss[n+1]={0}; for(int i=2;i<=sqrt(n);i++){ if(ss[i])continue; for(int j=i*i;j<=n;j+=i){ ss[j]=1; } } for(int i=2;i<=n;i++){ if(!ss[i])cout<<i<<' '; } return 0; }