Advertisement
rain36563120

zerojudge a121

May 24th, 2020
411
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.60 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int findprime(int x)
  5. {
  6.     int check=1;
  7.     for(int i=3;i<sqrt(x)+1;i+=2)
  8.         if(x%i==0)
  9.         {
  10.             check=0;
  11.             break;
  12.         }
  13.     return check;
  14. }
  15.  
  16. int main()
  17. {
  18.     int a,b;
  19.     while(cin>>a>>b)
  20.     {
  21.         int count=0,A[5]={2,3,5,7,11};
  22.         for(int i=a;i<=b;++i)
  23.             if(!(!(i%2)||!(i%3)||!(i%5)||!(i%7)||!(i%11))&&i!=1)
  24.                 count+=findprime(i);
  25.         for(int i=0;i<5;++i)
  26.             if(a<=A[i]&&A[i]<=b)
  27.                 ++count;
  28.         cout<<count<<endl;
  29.     }
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement