Saleh127

UVA 10200

Jul 7th, 2020
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define test int t; cin>>t; while (t--)
  4. #define ll long long int
  5. #define fellow_junior ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  6. int prime[10005];
  7. int sieve(int n)
  8. {
  9. int i,j;
  10. for(i=2;i*i<=n;i++)
  11. {
  12. if(n%i==0)
  13. {
  14. return 0;
  15. }
  16. }
  17. return 1;
  18. }
  19. int main()
  20. {
  21. fellow_junior
  22. int a,c,d,e,i,j,k,l;
  23. for(i=0;i<10005;i++)
  24. {
  25. prime[i]=sieve(i*i+i+41);
  26. }
  27. while(scanf("%d %d",&a,&c)!=EOF)
  28. {
  29. double ans=0;
  30. for(i=a;i<=c;i++)
  31. {
  32. ans+=prime[i];
  33. }
  34. double res=ans*1.0/(c-a+1)*100.00+1e-8;
  35. printf("%.2lf\n",res);
  36. }
  37. return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment