题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1141

  1. Sample Input
  2.  
  3. Sample Output
  4. 100.00
  5. 97.56
  6. 50.00
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <cstring>
  4. #include <algorithm>
  5. #include <cmath>
  6. #include <stack>
  7. #include <map>
  8. #include <vector>
  9. using namespace std;
  10.  
  11. #define N 12000
  12. #define INF 0x3f3f3f3f
  13.  
  14. int f[N];
  15.  
  16. int q(long long m)
  17. {
  18. int k=(int)sqrt(m);
  19. for(int i=;i<=k;i++)
  20. if(m%i==)
  21. return ;
  22. return ;
  23. }
  24.  
  25. int main()
  26. {
  27. int a,b;
  28. f[]=;
  29.  
  30. for(int i=;i<N;i++)
  31. f[i]=f[i-]+q(i*i+i+);
  32.  
  33. while(scanf("%d%d", &a,&b) != EOF)
  34. {
  35. double s;
  36. if(a==)
  37. s=1.0*f[b]/(b-a+);
  38. else
  39. s=1.0*(f[b]-f[a-])/(b-a+);
  40. printf("%.2f\n", s*+1e-);
  41. }
  42.  
  43. return ;
  44. }

UVA 10200 Prime Time (打表)的更多相关文章

  1. UVA 10200 Prime Time 水

    题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem ...

  2. UVA 10200 Prime Time【暴力,精度】

    题目链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_proble ...

  3. UVA - 10200 Prime Time 关于 double类型 卡精度

    题意: 给定一个区间,a到b, n在区间内,有一个计算素数的公式,n*n+n+41,将n带进去可以得出一个数字.但是这个公式可能不准确,求出这个公式在这个区间内的准确率. 直接模拟就好了,不过要 注意 ...

  4. UVA - 11827 - Maximum GCD,10200 - Prime Time (数学)

    两个暴力题.. 题目传送:11827 Maximum GCD AC代码: #include <map> #include <set> #include <cmath> ...

  5. UVA - 524 Prime Ring Problem(dfs回溯法)

    UVA - 524 Prime Ring Problem Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & % ...

  6. Prime Time UVA - 10200(精度处理,素数判定)

    Problem Description Euler is a well-known matematician, and, among many other things, he discovered ...

  7. 【数论】Prime Time UVA - 10200 大素数 Miller Robin 模板

    题意:验证1~10000 的数 n^n+n+41 中素数的个数.每个询问给出a,b  求区间[a,b]中质数出现的比例,保留两位 题解:质数会爆到1e8 所以用miller robin , 另外一个优 ...

  8. UVA 10140 - Prime Distance(数论)

    10140 - Prime Distance 题目链接 题意:求[l,r]区间内近期和最远的素数对. 思路:素数打表,打到sqrt(Max)就可以,然后利用大的表去筛素数.因为[l, r]最多100W ...

  9. UVa 1644 Prime Gap (水题,暴力)

    题意:给定一个数 n,求它后一个素数和前一个素数差. 析:先打表,再二分查找. 代码如下: #pragma comment(linker, "/STACK:1024000000,102400 ...

随机推荐

  1. 理解 Objective-C 的 ARC

    英文原文:Understanding Automatic Reference Counting in Objective-C 自动引用计数(Automatic Reference Counting, ...

  2. kindeditor编辑器,图片上传功能齐全

    废话不多说直接上文件包压缩包:kindeditor图片上传(VS2012)

  3. Unity3D 回合制 网上源码 目前还在研究构思

    我们已将回合制的战斗模式讲解得很清楚了.那么,如果在Unity3D游戏中实现一个回合制游戏呢?我们从最简单的一对一模式来设计回合制游戏的原型.我们可以游戏的状态划分为下面三种状态:        1. ...

  4. erlang四大behaviour之一gen_server

      来源:http://www.cnblogs.com/puputu/articles/1701017.html erlang程序设计里面有个设计原则就是把你的进程构造成树,把共用代码提出来,特定功能 ...

  5. 工作中遇到的http返回码

    普通常见的200.404.500,工作中遇到的还有206 .302 .304.400.403. 206----服务器返回部分数据 302----请求跳转 304----not modify 服务器内容 ...

  6. android 录制视频方式

    http://www.cnblogs.com/skyseraph/archive/2012/03/31/2427593.html http://bbs.csdn.net/topics/39088448 ...

  7. 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 ...

  8. SQL IO监控

    DBCC DROPCLEANBUFFERS --清空缓存 SET STATISTICS IO { ON | OFF } SET STATISTICS TIME { ON | OFF }

  9. CSS3秘笈:第十二章&第十三章

    第十二章 1.网页布局类型 (1)固定宽度 (2)流式 (3)响应式Web设计 2.CSS布局的方法 通过给元素设置一个宽度,将它浮到左侧或右侧,就可以创建一个列(元素后面的文本会环绕浮动的元素,仿佛 ...

  10. hud 2549 壮志难酬

    Problem Description 话说MCA山上各路豪杰均出山抗敌,去年曾在江湖威名显赫的,江湖人称<万军中取上将首级舍我其谁>的甘露也不甘示弱,“天将降大任于斯人也,必先劳其筋骨, ...