素数
文章平均质量分 78
h1021456873
这个作者很懒,什么都没留下…
展开
-
cf D. Dima and Lisa (三素数定理_素数打表+判定)
Dima loves representing an odd number as the sum of multiple primes, and Lisa loves it when there are at most three primes. Help them to represent the given number as the sum of at most than three pri原创 2015-10-07 11:40:40 · 734 阅读 · 2 评论 -
51nod 1181 质数中的质数(质数筛法)
如果一个质数,在质数列表中的编号也是质数,那么就称之为质数中的质数。例如:3 5分别是排第2和第3的质数,所以他们是质数中的质数。现在给出一个数N,求>=N的最小的质数中的质数是多少(可以考虑用质数筛法来做)。Input输入一个数N(N Output输出>=N的最小的质数中的质数。Input示例20Output示例31原创 2015-10-21 23:57:48 · 611 阅读 · 0 评论 -
POJ 3641 Pseudoprime numbers (伪素数_快速幂)
DescriptionFermat's theorem states that for any prime number p and for any integer a > 1, ap = a (mod p). That is, if we raise a to the pth power and divide by p, the remainder is a. Some (but n原创 2015-09-21 20:31:37 · 485 阅读 · 1 评论 -
统计素数+判断素数 模板
高效的判断素数:#include #include #include #include using namespace std;typedef long long LL;LL gcd(LL x, LL y){ if (!y) return x; return (y, x%y);}LL pow(LL a, LL x, LL mod){ LL ans原创 2015-08-15 21:58:13 · 574 阅读 · 0 评论 -
HDU Prime Ring Problem (DFS+素数打表)
Problem DescriptionA ring is compose of n circles as shown in diagram. Put natural number 1, 2, ..., n into each circle separately, and the sum of numbers in two adjacent circles should be a prime原创 2015-08-14 14:40:49 · 626 阅读 · 0 评论 -
51nod 1106 质数检测 (三种模板_好题)
Input第1行:一个数N,表示正整数的数量。(1 <= N <= 1000)第2 - N + 1行:每行1个数(2 Output输出共N行,每行为 Yes 或 No。Input示例523456Output示例YesYesNoYesNo效率最低:#include#include#includeusing n原创 2015-10-15 21:09:22 · 1186 阅读 · 0 评论