UVA 10200 Prime Time (打表)
题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1141
Sample Input Sample Output
100.00
97.56
50.00
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <stack>
#include <map>
#include <vector>
using namespace std; #define N 12000
#define INF 0x3f3f3f3f int f[N]; int q(long long m)
{
int k=(int)sqrt(m);
for(int i=;i<=k;i++)
if(m%i==)
return ;
return ;
} int main()
{
int a,b;
f[]=; for(int i=;i<N;i++)
f[i]=f[i-]+q(i*i+i+); while(scanf("%d%d", &a,&b) != EOF)
{
double s;
if(a==)
s=1.0*f[b]/(b-a+);
else
s=1.0*(f[b]-f[a-])/(b-a+);
printf("%.2f\n", s*+1e-);
} return ;
}
UVA 10200 Prime Time (打表)的更多相关文章
- UVA 10200 Prime Time 水
题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem ...
- UVA 10200 Prime Time【暴力,精度】
题目链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_proble ...
- UVA - 10200 Prime Time 关于 double类型 卡精度
题意: 给定一个区间,a到b, n在区间内,有一个计算素数的公式,n*n+n+41,将n带进去可以得出一个数字.但是这个公式可能不准确,求出这个公式在这个区间内的准确率. 直接模拟就好了,不过要 注意 ...
- UVA - 11827 - Maximum GCD,10200 - Prime Time (数学)
两个暴力题.. 题目传送:11827 Maximum GCD AC代码: #include <map> #include <set> #include <cmath> ...
- UVA - 524 Prime Ring Problem(dfs回溯法)
UVA - 524 Prime Ring Problem Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & % ...
- Prime Time UVA - 10200(精度处理,素数判定)
Problem Description Euler is a well-known matematician, and, among many other things, he discovered ...
- 【数论】Prime Time UVA - 10200 大素数 Miller Robin 模板
题意:验证1~10000 的数 n^n+n+41 中素数的个数.每个询问给出a,b 求区间[a,b]中质数出现的比例,保留两位 题解:质数会爆到1e8 所以用miller robin , 另外一个优 ...
- UVA 10140 - Prime Distance(数论)
10140 - Prime Distance 题目链接 题意:求[l,r]区间内近期和最远的素数对. 思路:素数打表,打到sqrt(Max)就可以,然后利用大的表去筛素数.因为[l, r]最多100W ...
- UVa 1644 Prime Gap (水题,暴力)
题意:给定一个数 n,求它后一个素数和前一个素数差. 析:先打表,再二分查找. 代码如下: #pragma comment(linker, "/STACK:1024000000,102400 ...
随机推荐
- LINQ的Any() 方法
Enumerable.Any 方法 确定序列中的任何元素是否存在或满足条件.
- ural 1013. K-based Numbers. Version 3(动态规划)
1013. K-based Numbers. Version 3 Let’s consider K-based numbers, containing exactly N digits. We def ...
- Html加载swf 兼容IE8 (含以下)显示
嵌入参数说明: 1,AllowScriptAccess 参数: sameDomain:仅当 SWF 文件和网页位于同一域中时才允许执行外出脚本访问.这是 AVM2 内容的默认值----播放网络视频, ...
- NYOJ-791 Color the fence (贪心)
Color the fence 时间限制:1000 ms | 内存限制:65535 KB 难度:2 描述 Tom has fallen in love with Mary. Now Tom w ...
- NYOJ-915 +-字符串(贪心)
+-字符串 时间限制:1000 ms | 内存限制:65535 KB 难度:1 描述 Shiva得到了两个只有加号和减号的字符串,字串长度相同.Shiva一次可以把一个加号和它相邻的减号交换. ...
- 关于UIFont和计算字符串的高度和宽度
转自:http://i.cnblogs.com/EditPosts.aspx?opt=1 1.创建方法:+ fontWithName:size:- fontWithSize:2.创建系统字体:+ sy ...
- Linux通过XAMPP集成软件包搭建LAMPP环境
前面介绍过一篇“Linux手动搭建LAMP环境”,今天再来整理一篇“Linux通过XAMPP集成软件包搭建LAMPP环境”. 其实当初整理通过XAMPP集成软件包搭建LAMPP环境的原因是这样的: 自 ...
- iOS 打电话、发短信、发邮件功能
打电话 方法1 最简单最直接的方式:直接跳到拨号界面 NSURL *url = [NSURL URLWithString:@"tel://10010"]; [[UIApplicat ...
- websphere安装验证报错 忘记密码的配置
http://blog.csdn.net/yulimin/article/details/4048897 ADMU7704E: 在尝试启动与服务器相关联的 Windows 服务时失败:server1: ...
- 利用朴素贝叶斯算法进行分类-Java代码实现
http://www.crocro.cn/post/286.html 利用朴素贝叶斯算法进行分类-Java代码实现 鳄鱼 3个月前 (12-14) 分类:机器学习 阅读(44) 评论(0) ...