Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
3098 邓小龙 判断素数II C++ Accepted 0 MS 276 KB 436 2024-04-04 22:50:34

Tests(10/10):


Code:

#include<iostream> using namespace std; bool a[50000005]; void su(int x){ int shu=0; a[0]=a[1]=1; for(int i=2;i<=x/i;i++){ if(!a[i]){ for(int j=i*i;j<=x;j+=i){ a[j]=1; } } } for(int i=1;i<=x;i++){ if(!a[i]){ shu++; } } cout<<shu<<endl; } int main(){ int b; cin>>b; su(b); return 0; }