UVA10200 Prime Time
/*
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的更多相关文章
- UVA-10200 Prime Time 素数(注意除法精度)
题目链接:https://cn.vjudge.net/problem/UVA-10200 题意 给出一个公式$ m=n^2+n+41, n \in Z^+ $ 现在$ a,b\in[0, 10000] ...
- Java 素数 prime numbers-LeetCode 204
Description: Count the number of prime numbers less than a non-negative number, n click to show more ...
- Prime Generator
Peter wants to generate some prime numbers for his cryptosystem. Help him! Your task is to generate ...
- POJ 2739. Sum of Consecutive Prime Numbers
Sum of Consecutive Prime Numbers Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 20050 ...
- UVa 524 Prime Ring Problem(回溯法)
传送门 Description A ring is composed of n (even number) circles as shown in diagram. Put natural numbe ...
- Sicily 1444: Prime Path(BFS)
题意为给出两个四位素数A.B,每次只能对A的某一位数字进行修改,使它成为另一个四位的素数,问最少经过多少操作,能使A变到B.可以直接进行BFS搜索 #include<bits/stdc++.h& ...
- hdu 5901 count prime & code vs 3223 素数密度
hdu5901题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5901 code vs 3223题目链接:http://codevs.cn/problem ...
- 最小生成树 prime zoj1586
题意:在n个星球,每2个星球之间的联通需要依靠一个网络适配器,每个星球喜欢的网络适配器的价钱不同,先给你一个n,然后n个数,代表第i个星球喜爱的网络适配器的价钱,然后给出一个矩阵M[i][j]代表第i ...
- 最小生成树 prime poj1258
题意:给你一个矩阵M[i][j]表示i到j的距离 求最小生成树 思路:裸最小生成树 prime就可以了 最小生成树专题 AC代码: #include "iostream" #inc ...
随机推荐
- csu 1030: 素数槽
素数槽 Description 处于相邻的两个素数p和p + n之间的n - 1个连续的合数所组成的序列我们将其称为长度为n的素数槽.比如,‹24, 25, 26, 27, 28›是处于素数23 ...
- js中简单操作
去空格:ss.replace(/\s/g,""); 数组: 千万不能用in操作符 in 是说存不存在这个key而不是value! var a = [66,99,77]; 66 in ...
- JFinal Starting scanner at interval of 5 seconds.报错
Starting JFinal 2.0 Starting scanner at interval of 5 seconds. Starting web server on port: 80 Excep ...
- Task.ConfigureAwait
public ConfiguredTaskAwaitable ConfigureAwait( bool continueOnCapturedContext ) Configures an awaite ...
- 关于java1.8中LocalDateTime实现日期,字符串互转小坑。
今天无聊,来看了下1.8的时间类型LocalDateTime,当想把字符串转成LocalDateTime的时候报错!! java.time.format.DateTimeParseException: ...
- Mybatis中resultMap的作用-解决实体类属性名和数据库字段不一致
解决实体类属性名和数据库字段不一致
- [转]C# ListView 单击标题实现排序(在转载的基础上有所完善)
using System; using System.Collections; using System.Windows.Forms; //在转载的基础上有所完善 namespace TDRFacto ...
- html中DTD使用小结
DTD 是一套关于标记符的语法规则.它是XML1.0版规格得一部分,是html文件的验证机制,属于html文件组成的一部分. DTD:三种文档类型:S(Strict).T(Transitional). ...
- C# DataTable常用方法总结
https://blog.csdn.net/wangzhen209/article/details/51743118
- TensorFlow-正弦函数拟合
MNIST的代码还是有点复杂,一大半内容全在搞数据,看了半天全是一滩烂泥.最关键的是最后输出就是一个accuracy,我根本就不关心你准确率是0.98还是0.99好吗?我就想看到我手写一个5,你程序给 ...