Run ID | Author | Problem | Lang | Verdict | Time | Memory | Code Length | Submit Time |
---|---|---|---|---|---|---|---|---|
41015 | liusiyu | 素数个数 | C++ | Accepted | 0 MS | 256 KB | 297 | 2024-02-18 15:59:44 |
//找素数 #include<iostream> using namespace std; int main() { int m; cin>>m; bool sushu=true; int cnt=1; for(int i=2;i<=m;i++){ sushu=true; for(int j=2;j*j<=i;j++){ if(i%j==0){ break; } else{ cnt++; break; } } } cout<<cnt<<endl; }