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 ...
随机推荐
- 理解 Objective-C 的 ARC
英文原文:Understanding Automatic Reference Counting in Objective-C 自动引用计数(Automatic Reference Counting, ...
- kindeditor编辑器,图片上传功能齐全
废话不多说直接上文件包压缩包:kindeditor图片上传(VS2012)
- Unity3D 回合制 网上源码 目前还在研究构思
我们已将回合制的战斗模式讲解得很清楚了.那么,如果在Unity3D游戏中实现一个回合制游戏呢?我们从最简单的一对一模式来设计回合制游戏的原型.我们可以游戏的状态划分为下面三种状态: 1. ...
- erlang四大behaviour之一gen_server
来源:http://www.cnblogs.com/puputu/articles/1701017.html erlang程序设计里面有个设计原则就是把你的进程构造成树,把共用代码提出来,特定功能 ...
- 工作中遇到的http返回码
普通常见的200.404.500,工作中遇到的还有206 .302 .304.400.403. 206----服务器返回部分数据 302----请求跳转 304----not modify 服务器内容 ...
- android 录制视频方式
http://www.cnblogs.com/skyseraph/archive/2012/03/31/2427593.html http://bbs.csdn.net/topics/39088448 ...
- A. Night at the Museum Round#376 (Div. 2)
A. Night at the Museum time limit per test 1 second memory limit per test 256 megabytes input standa ...
- SQL IO监控
DBCC DROPCLEANBUFFERS --清空缓存 SET STATISTICS IO { ON | OFF } SET STATISTICS TIME { ON | OFF }
- CSS3秘笈:第十二章&第十三章
第十二章 1.网页布局类型 (1)固定宽度 (2)流式 (3)响应式Web设计 2.CSS布局的方法 通过给元素设置一个宽度,将它浮到左侧或右侧,就可以创建一个列(元素后面的文本会环绕浮动的元素,仿佛 ...
- hud 2549 壮志难酬
Problem Description 话说MCA山上各路豪杰均出山抗敌,去年曾在江湖威名显赫的,江湖人称<万军中取上将首级舍我其谁>的甘露也不甘示弱,“天将降大任于斯人也,必先劳其筋骨, ...