6 solutions
-
-3
#include <bits/stdc++.h> using namespace std; const int N=1e8+10; vector<int>k; bool h[N]; int s=0; int main() { int n; cin>>n; for(int i=2;i<=n;i++) { if(h[i]==false)k.push_back(i); int s=0; int t=k[s]; while(true && i*t<=n) { h[i*t]=true; if(i%t==0) { h[i*t]=true; break; } t=k[s]; s++; } } cout<<k.size(); return 0; }
Information
- ID
- 181
- Time
- 2000ms
- Memory
- 256MiB
- Difficulty
- 5
- Tags
- (None)
- # Submissions
- 153
- Accepted
- 22
- Uploaded By