yoyoboyss

Untitled

Feb 13th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. const int NMAX=2000005;
  5. ifstream fin("ciur.in");
  6. ofstream fout("ciur.out");
  7.  
  8. int A[NMAX];
  9. int N, v[NMAX], S=0;
  10.  
  11. void Ciur(){
  12. for(int i = 2; i * i <= N; i++)
  13. if(!A[i]){
  14. for(int j = i * i; j <= N; j += i)
  15. A[j] = true;
  16. }
  17. }
  18.  
  19. int main(){
  20. fin >> N; Ciur();
  21. for(int i = 2; i <= N; i++)
  22. S += !A[i];
  23.  
  24. fout << S << '\n';
  25.  
  26. return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment