可以吃饭啦!!! A:连通块 ZOJ 1709 Oil Deposits(dfs,连通块个数) B:素数变换 打表+bfs POJ 3216 Prime Path(打表+bfs) C:水bfs HDU 2717 Catch That Cow(常规bfs) D:bfs+状态压缩 HDU 1429 胜利 ...
分类:
其他好文 时间:
2018-07-30 20:19:30
阅读次数:
201
Relatives Given n, a positive integer, how many positive integers less than n are relatively prime to n? Two integers a and b are relatively prime if ...
分类:
其他好文 时间:
2018-07-29 22:32:47
阅读次数:
180
Primitive Roots We say that integer x, 0 < x < p, is a primitive root modulo odd prime p if and only if the set { (x i mod p) | 1 <= i <= p-1 } is equ ...
分类:
其他好文 时间:
2018-07-29 22:19:45
阅读次数:
161
这道题中由于素数的范围只有10000(比较小),因此可以计算出10000以内的所有素数,存储到一个数组中,方便计算素数和的时候使用。 因为一个素数的倍数都不是素数,所以可以从2的倍数开始剔除,2的倍数剔除完后剔除3的倍数,......,以此类推。 计算完素数后需要计算一个正整有多少个连续素数的表示 ...
分类:
其他好文 时间:
2018-07-29 19:01:49
阅读次数:
146
The ministers of the cabinet were quite upset by the message from the Chief of Security stating that they would all have to change the four-digit room ...
分类:
其他好文 时间:
2018-07-28 18:19:26
阅读次数:
142
A reversible prime in any number system is a prime whose "reverse" in that number system is also a prime. For example in the decimal system 73 is a re ...
分类:
其他好文 时间:
2018-07-28 12:07:02
阅读次数:
126
欧拉筛可以$O(n)$筛素数,其本质是拿每个合数的最小质因子把这个合数筛掉。 cpp void prime(int m) { memset(flag, 1, sizeof flag); cnt = 0; for(int i=2; i ...
分类:
其他好文 时间:
2018-07-27 18:09:49
阅读次数:
149
1 bool Is_Prime(int n){ 2 if (n < 2) return false; 3 for (int i = 2; i <= sqrt(n); i++){ 4 if (n%i == 0) return false; 5 } 6 return true; 7 } ...
分类:
其他好文 时间:
2018-07-26 18:44:39
阅读次数:
114
https://www.lydsy.com/JudgeOnline/problem.php?id=2705 先化简。。 化简出来,这个函数就是$id*id*\mu=id*\varphi$ 可以暴力枚举n的因子求。。 ...
分类:
其他好文 时间:
2018-07-26 18:29:47
阅读次数:
123
尽管能计算得到尾后指针,但这种用法极易出错。为了让指针的使用更简单、更安全,c++新标准引入了两个名为begin和end的函数。这两个函数与容器中的两个同名成员功能类似,不过数组毕竟不是类类型,因此这两个函数不是成员函数。正确的使用形式是将数组作为它们的参数: 不能用动态数组 这两个函数定义在ite ...
分类:
编程语言 时间:
2018-07-26 15:17:41
阅读次数:
185