/*
UVA10200 Prime Time
https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1141
素数 概率论 暴力 输出的时候加1e-5到1e-14都能过,不加就wa,不是很懂
*
*
*
*/
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
const int Nmax=;
#define dabiao
#ifdef dabiao
int f[Nmax];
int num[Nmax];
int is_prime(long long n)
{
long long sqr=sqrt(n);
for(int i=;i<=sqr+;i++)
if(n%i==)
return ;
return ;
} inline long long get(long long a)
{
return a*a+a+;
} int main()
{
for(int i=;i<Nmax;i++)
{
f[i]=is_prime(get(i));
if(i==)
num[i]=f[i];
else
num[i]=f[i]+num[i-];
}
int a,b;
while(scanf("%d%d",&a,&b)==)
{
if(a==)
printf("%.2lf\n",100.0*num[b]*1.0/((b+)*1.0)+1e-);
else
printf("%.2lf\n",100.0*(num[b]*1.0-num[a-]*1.0)/(b*1.0-a*1.0+)+1e-);
}
return ;
} #endif

UVA10200 Prime Time的更多相关文章

  1. UVA-10200 Prime Time 素数(注意除法精度)

    题目链接:https://cn.vjudge.net/problem/UVA-10200 题意 给出一个公式$ m=n^2+n+41, n \in Z^+ $ 现在$ a,b\in[0, 10000] ...

  2. Java 素数 prime numbers-LeetCode 204

    Description: Count the number of prime numbers less than a non-negative number, n click to show more ...

  3. Prime Generator

    Peter wants to generate some prime numbers for his cryptosystem. Help him! Your task is to generate ...

  4. POJ 2739. Sum of Consecutive Prime Numbers

    Sum of Consecutive Prime Numbers Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 20050 ...

  5. UVa 524 Prime Ring Problem(回溯法)

    传送门 Description A ring is composed of n (even number) circles as shown in diagram. Put natural numbe ...

  6. Sicily 1444: Prime Path(BFS)

    题意为给出两个四位素数A.B,每次只能对A的某一位数字进行修改,使它成为另一个四位的素数,问最少经过多少操作,能使A变到B.可以直接进行BFS搜索 #include<bits/stdc++.h& ...

  7. hdu 5901 count prime & code vs 3223 素数密度

    hdu5901题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5901 code vs 3223题目链接:http://codevs.cn/problem ...

  8. 最小生成树 prime zoj1586

    题意:在n个星球,每2个星球之间的联通需要依靠一个网络适配器,每个星球喜欢的网络适配器的价钱不同,先给你一个n,然后n个数,代表第i个星球喜爱的网络适配器的价钱,然后给出一个矩阵M[i][j]代表第i ...

  9. 最小生成树 prime poj1258

    题意:给你一个矩阵M[i][j]表示i到j的距离 求最小生成树 思路:裸最小生成树 prime就可以了 最小生成树专题 AC代码: #include "iostream" #inc ...

随机推荐

  1. Create and Call HttpHandler in SharePoint

    Create and Call HttpHandler in SharePoint Requirement: 1. Create a httphandler, and reture json data ...

  2. PbootCMS V1.1.4 正式发布

    PbootCMS V1.1.4 正式发布 PbootCMS V1.1.4 build 2018-06-251.修复自定义表单表名重复仍然添加成功问题:2.修复分享到微信导致页面错误的问题:3.修复静态 ...

  3. python TypeError: &#39;builtin_function_or_method&#39; object is not iterable keys

    statinfo = os.stat( OneFilePath ) if AllFiles.has_key( statinfo.st_size ): OneKey = AllFiles[ statin ...

  4. wpf Listbox 设置ItemContainerStyle后,ItemTemplateSelector不能触发

    解决方案: 将Listbox 的ItemTemplateSelector 改为 ItemContainerStyle中ContentPresenter ContentTemplateSelector ...

  5. leetCode 20.Valid Parentheses (有效的括号) 解题思路和方法

    Valid Parentheses  Given a string containing just the characters '(', ')', '{', '}', '[' and ']', de ...

  6. 922. 按奇偶排序数组 II

    给定一个非负整数数组 A, A 中一半整数是奇数,一半整数是偶数. 对数组进行排序,以便当 A[i] 为奇数时,i 也是奇数:当 A[i] 为偶数时, i 也是偶数. 你可以返回任何满足上述条件的数组 ...

  7. Java基础学习分享

    一.Java介绍 Java是由原Sun公司(现已被甲骨文公司收购)于1991年开发的编程语言,初衷是为智能家电的程序设计提供一个分布式代码系统.为了使整个系统与平台无关,采用了虚拟机器码方式,虚拟机内 ...

  8. testNG中方法的调用顺序

    今天在执行selnium的test case时,总是遇到空指针错误.但是以前也有run成功过,然后换了各种方法定位元素,都失败了,所以怀疑应该不是元素定位不到的问题,所以可能是method之间有依赖, ...

  9. 10.2&10.3 Xcode开发包

    10.2开发包下载链接 10.3开发包下载链接 Finder打开后,按command+shift+G前往这个地址: /Applications/Xcode.app/Contents/Developer ...

  10. 文件操作:Directory,File,FielStream、StreamRead和StreamWriter的使用

    Directory文件类,File,FielStream.StreamRead和StreamWriter的使用 (转载) 创建一个新文件 Directory.CreateDirectory(@&quo ...