Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
3083 | 吴奕希 | 判断素数II | C++ | Accepted | 0 MS | 292 KB | 482 | 2024-04-03 19:19:33 |
# include<iostream> # include<cmath> using namespace std; bool isprimes[5000001]={}; int primes[5000001]={}; int n = 0, j = 0; int main(){ int x; cin>>x; for(int i = 2; i <= x; i++){ if(isprimes[i]==0){ primes[n]=i; n++; } j = 0; do{ isprimes[i*primes[j]]=1; if(i%primes[j]==0)break; j++; }while(i*primes[j]<=x); } cout<<n; return 0; }