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 <alg…
题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1141 题意:判断区间[a,b]的f(i)是否为素数,f(i)=i*i+i+40: 思路:打个表,然后注意精度: #include<bits/stdc++.h> using namespace std; #define ll long long #define esp…
题目链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1141 题意: 给定区间,求区间内所有整数a,f(a) = a * a + a - 1为质数的概率. 分析: 卡精度卡的蛋疼.. 最后要加个eps处理四舍五入问题..不是很懂.. 代码: #include<cstdio> const int maxm = 1e4 +…
题意: 给定一个区间,a到b, n在区间内,有一个计算素数的公式,n*n+n+41,将n带进去可以得出一个数字.但是这个公式可能不准确,求出这个公式在这个区间内的准确率. 直接模拟就好了,不过要 注意 :直接对1到10000的数据打一个表,要不然会超时,在卡精度的时候加上一个1e-6或者1e-8,这东西有点说不清为什么,先记着,就像浮点型数据不能直接比较大小一样,比如: 定义一个浮点型的a和b,当判断a==b时,if(a-b<1e-6) #include<math.h> #include…
两个暴力题.. 题目传送:11827 Maximum GCD AC代码: #include <map> #include <set> #include <cmath> #include <deque> #include <queue> #include <stack> #include <cstdio> #include <cctype> #include <string> #include <…
UVA - 524 Prime Ring Problem Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Description A ring is composed of n (even number) circles as shown in diagram. Put natural numbers  into each circle separately, and the sum of number…
Problem Description Euler is a well-known matematician, and, among many other things, he discovered that the formulan^{2} + n + 41n2+n+41 produces a prime for 0 ≤ n < 400≤n<40. For n = 40n=40, the formula produces 16811681, which is 41 ∗ 4141∗41.Eve…
题意:验证1~10000 的数 n^n+n+41 中素数的个数.每个询问给出a,b  求区间[a,b]中质数出现的比例,保留两位 题解:质数会爆到1e8 所以用miller robin , 另外一个优化是预处理 一个坑是四舍五入卡精度. #include<stdio.h> #include<stdlib.h> #include<string.h> #include<algorithm> #include<iostream> #include<…
10140 - Prime Distance 题目链接 题意:求[l,r]区间内近期和最远的素数对. 思路:素数打表,打到sqrt(Max)就可以,然后利用大的表去筛素数.因为[l, r]最多100W.所以能够去遍历一遍.找出答案. 注意1的情况,一開始没推断1,结果WA了 代码: #include <stdio.h> #include <string.h> #include <algorithm> using namespace std; #define INF 0x…
题意:给定一个数 n,求它后一个素数和前一个素数差. 析:先打表,再二分查找. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <cstdlib> #include <cmath> #include <iostream> #include <cstring&…