Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- typedef long long int ll;
- bool mark[100006];
- bool isprime(ll n)
- {
- for(int i=2;i*i<=n;i++)
- {
- if(n%i==0)
- return false;
- }
- return true;
- }
- void precal()
- {
- for(ll i=0; i<=39; i++)
- mark[i]=true;
- for(ll i=40; i<=10005; i++)
- {
- ll c=(i*i)+i+41;
- if(isprime(c)==true)
- mark[i]=true;
- }
- }
- int main()
- {
- ll a,b,c,d,i,j;
- precal();
- while(cin>>a>>b)
- {
- double lob=0,hor=b-a+1;
- for(i=a;i<=b;i++)
- {
- if(mark[i]==true)
- lob++;
- }
- double ans=lob/hor;
- ans*=100.0;
- printf("%.2lf\n",ans+1e-8);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement