Advertisement
Farjana_akter

Untitled

Feb 14th, 2020
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. typedef long long int ll;
  4. bool mark[100006];
  5. bool isprime(ll n)
  6. {
  7. for(int i=2;i*i<=n;i++)
  8. {
  9. if(n%i==0)
  10. return false;
  11. }
  12. return true;
  13. }
  14. void precal()
  15. {
  16. for(ll i=0; i<=39; i++)
  17. mark[i]=true;
  18. for(ll i=40; i<=10005; i++)
  19. {
  20. ll c=(i*i)+i+41;
  21. if(isprime(c)==true)
  22. mark[i]=true;
  23. }
  24. }
  25.  
  26.  
  27. int main()
  28. {
  29. ll a,b,c,d,i,j;
  30. precal();
  31.  
  32. while(cin>>a>>b)
  33. {
  34. double lob=0,hor=b-a+1;
  35. for(i=a;i<=b;i++)
  36. {
  37. if(mark[i]==true)
  38. lob++;
  39. }
  40. double ans=lob/hor;
  41. ans*=100.0;
  42. printf("%.2lf\n",ans+1e-8);
  43. }
  44. return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement