Advertisement
nicuvlad76

Untitled

Nov 19th, 2022
633
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.47 KB | None | 0 0
  1. #include <fstream>
  2. #define N 500001
  3. using namespace std;
  4. ifstream fin ("eratostene1.in");
  5. ofstream fout ("eratostene1.out");
  6. bool ciur[N];
  7. int n,i,x,j;
  8. int ct=0;
  9. int main()
  10. {
  11.     ///ciur
  12.     for(int i=1;i<N;i++)
  13.         if(ciur[i]==0)
  14.          for(j=3*i+1;j<N;j+=(i<<1)+1)
  15.            ciur[j]=1;
  16.     fin>>n;
  17.     while(n--)
  18.     {
  19.         fin>>x;
  20.         if(x==2) x++;
  21.         if(x%2==1)
  22.              ct+=1-ciur[(x>>1)];
  23.     }
  24.     fout<<ct;
  25.     return 0;
  26. }
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement