Saleh127

e-olym 33

Sep 10th, 2020
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define test int t; cin>>t; for(int cs=1;cs<=t;cs++)
  5. bool check(ll x)
  6. {
  7. while(x>0)
  8. {
  9. if((x%10)==3 && (x/10)%10==1) return 0;
  10. x/=10;
  11. }
  12. return 1;
  13. }
  14.  
  15. bool prime(ll s)
  16. {
  17. if(s==2) return 1;
  18. if(s==1 || s%2==0) return 0;
  19. for(ll i=3;i*i<=s;i+=2)
  20. {
  21. if(s%i==0) return 0;
  22. }
  23. return 1;
  24. }
  25.  
  26. int main()
  27. {
  28. ios_base::sync_with_stdio(0);
  29. cin.tie(0);cout.tie(0);
  30.  
  31. ll a,c,i,j,k=0;
  32. cin>>a>>c;
  33. for(i=a;i<=c;i++)
  34. {
  35. if(prime(i) && check(i))
  36. {
  37. k++;
  38. }
  39. }
  40. cout<<k<<endl;
  41.  
  42. return 0;
  43. }
  44.  
Advertisement
Add Comment
Please, Sign In to add comment