uva10200
来源:互联网 发布:老人去世无人知 编辑:程序博客网 时间:2024/05/19 17:09
注意精度。
/* ***********************************************Author : rycCreated Time : 2016-08-14 SundayFile Name : E:\acm\大三暑假\uva10200.cppLanguage : c++Copyright 2016 ryc All Rights Reserved************************************************ */#include<iostream>#include<cstdio>#include<cstdlib>#include<algorithm>#include<cstring>#include<queue>#include<list>#include<stack>#include<vector>#include<map>using namespace std;typedef long long LL;typedef pair<int,int>pii;const int maxn=10010;double ans[maxn];bool judge(LL n){ for(LL i=2;i*i<=n;++i){ if(n%i==0)return false; } return true;}void Count(){ ans[0]=1; for(LL i=1;i<maxn;++i){ if(judge(i*i+i+41)){ ans[i]=ans[i-1]+1; } else { ans[i]=ans[i-1]; } }}int main(){ Count(); int a,b; while(scanf("%d%d",&a,&b)!=EOF){ if(a==0){ printf("%.2lf\n",ans[b]*1.0/(b+1)*100.0+1e-8); } else { printf("%.2lf\n",(double)(1.0*(ans[b]-ans[a-1])*1.0/(b-a+1))*100.0+1e-8); } } return 0;}
0 0
- uva10200
- uva10200 Prime Time
- UVA10200 Prime Time【素数判定】
- UVA10200-Prime Time/HDU2161-Primes,例题讲解,牛逼的费马小定理和欧拉函数判素数。
- 文章标题
- java中form以post、get方式提交数据中文乱码问题总结
- 封装windows 线程创建函数_beginthreadex和createthread函数的类
- TreeMap详细介绍(源码解析)和使用示例
- grep命令详解
- uva10200
- POJ 1386-Play on Words(有向欧拉通路)
- Android简易实战教程--第十七话《自定义彩色环形进度条》
- [leetcode] 64. Minimum Path Sum
- u-boot编译分析
- HTTP_cookie
- 数组应用——高精度运算的实验范例
- 机房收费系统总结
- osi模型和tcp udp的比较