Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
111122 万隽宇 素数检测 C++ Accepted 48 MS 3188 KB 518 2025-02-27 18:42:55

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; bool ip[n+1]={0}; int main(){ for(int i=2;i*i<=n;i++){ if(ip[i]) continue; for(int j=i*i;j<=n;j+=i) ip[j]=1; } for(int i=2;i<=n;i++){ if(!ip[i]){ cout<<i<<" "; } } return 0; }