其正确性思考写在了代码片上
#include
#include
#include
int phi[5000000];
///考虑到若所计算的数字是6,当i=2和i=3时都将会进入内层循环,
///一旦进入内层循环就会在该素数的基础上进行欧拉公式的运算
///插入:欧拉公式:phi(n)=n*(1-1/p1)*(1-1/p2)*...(1-1/pn)
///可以想到对于每一个确定的数字n来说...
分类:
其他好文 时间:
2014-08-12 17:19:34
阅读次数:
217
HDU 2588 GCD (欧拉函数)
只知道是个模板题目,其他的还是百度的。...
分类:
其他好文 时间:
2014-08-12 13:49:14
阅读次数:
193
定义:求小于n与n互素的整数个数。
推导公式:
ans = n(1-1/p1)(1-1/p2)..........(1-1/pk); 其中pi为n的质因子
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#...
分类:
其他好文 时间:
2014-08-12 13:36:44
阅读次数:
170
Problem Description
欧拉回路是指不令笔离开纸面,可画过图中每条边仅一次,且可以回到起点的一条回路。现给定一个图,问是否存在欧拉回路?
Input
测试输入包含若干测试用例。每个测试用例的第1行给出两个正整数,分别是节点数N ( 1
束。
Output
每个测试用例的输出占一行,若欧拉回路存在则输出1,否则输出0。
...
分类:
其他好文 时间:
2014-08-12 10:24:03
阅读次数:
164
题目:求 q/p 二进制小数的循环节,起点和长度。
若满足 2^phi[ n ] = 1 (mod n ) 则 数 t = phi [ n ] 一定有一个使 2^k=1 (mod n )成立的 因子 k
#include
#include
#include
#include
#include
#include
#define bug(a) cout\n";
#defin...
分类:
其他好文 时间:
2014-08-11 17:51:52
阅读次数:
183
//1.联通图 2.顶点度数都为偶数 ,则存在欧拉回路。
# include
# include
# include
using namespace std;
int father[1010];
int vis[1010][1010],du[1010];
int find(int x)
{
if(father[x]==x)
return x;
return f...
分类:
其他好文 时间:
2014-08-10 10:25:30
阅读次数:
218
Description
Ouroboros is a mythical snake from ancient Egypt. It has its tail in its mouth and continously devours itself.
The Ouroboros numbers are binary numbers of 2^n bits that have the prop...
分类:
其他好文 时间:
2014-08-09 11:40:57
阅读次数:
315
1 /* 2 NYOJ 99单词拼接: 3 思路:欧拉回路或者欧拉路的搜索! 4 注意:是有向图的!不要当成无向图,否则在在搜索之前的判断中因为判断有无导致不必要的搜索,以致TLE! 5 有向图的欧拉路:abs(In[i] - Out[i])==1(入度[i] -...
分类:
其他好文 时间:
2014-08-09 02:31:46
阅读次数:
357
链接:http://acm.hdu.edu.cn/showproblem.php?pid=1695
题意:在[a,b]中的x,在[c,d]中的y,求x与y的最大公约数为k的组合有多少。(a=1, a
思路:因为x与y的最大公约数为k,所以xx=x/k与yy=y/k一定互质。要从a/k和b/k之中选择互质的数,枚举1~b/k,当选择的yy小于等于a/k时,可以选择的xx数为Euler(yy),...
分类:
其他好文 时间:
2014-08-09 00:17:26
阅读次数:
272
Description
KEY Inc., the leading company in security hardware, has developed a new kind of safe. To unlock it, you don't need a key but you are required to enter the correct n-digit code on a keyp...
分类:
其他好文 时间:
2014-08-09 00:16:16
阅读次数:
351