链接:http://poj.org/problem?id=3090
题意:在坐标系中,从横纵坐标 0 ≤ x, y ≤
N中的点中选择点,并且这些点与(0,0)的连点不经过其他的点。
思路:显而易见,x与y只有互质的情况下才会发生(0,0)与(x,y)交点不经过其他的点的情况,对于x,y等于N时,可以选择的点均为小于等于N并且与N互质的数,共Euler(N)个,并且不重叠。所以可以得到递推...
分类:
其他好文 时间:
2014-07-31 00:02:15
阅读次数:
240
Primitive Roots
题目链接:http://poj.org/problem?id=1284
利用定理:素数 P 的原根的个数为euler(p - 1)
typedef long long ll;
using namespace std;
/*
求原根
g^d ≡ 1(mod p) 其中d最小为p-1,g 便是一个原根
复杂度:O(m)*lo...
分类:
其他好文 时间:
2014-07-30 20:43:34
阅读次数:
260
1. 欧拉通路、欧拉回路、欧拉图无向图:1) 设G是连通无向图,则称经过G的每条边一次并且仅一次的路径为欧拉通路;2) 如果欧拉通路是回路(起点和终点是同一个顶点),则称此回路为欧拉回路(Euler circuit);3) 具有欧拉回路的无向图G称为欧拉图(Euler graph)。有向图:1...
分类:
其他好文 时间:
2014-07-30 11:59:13
阅读次数:
261
一:素数的基本求法:bool pd(int x){ if(x==1)return false; for(int i=2;i*i1。那么必然存在点(x/k,y/k),会挡住(x,y)。问题就变成了:求1-N中,所有与N互质的数的个数。这不就是欧拉函数....so,ans=(euler(1)...
分类:
其他好文 时间:
2014-07-28 11:30:40
阅读次数:
240
1.欧拉函数的定义: 欧拉函数phi(x)等于不超过x且与x互素的整数的个数。2.欧拉函数的求法:推导过程见随笔《欧拉函数与容斥原理》.3.代码实现欧拉函数: 1 int euler_phi(int n) 2 { 3 int m=(int)sqrt(n+0.5);//取一半就行,简化计算 4...
分类:
其他好文 时间:
2014-07-28 11:19:00
阅读次数:
184
#include #include using namespace std;//点(x,y)可见当且仅当x,y互质,那么我仅仅只要知道int euler(int x){// 就是公式 int i, res=x,tmp; tmp= (int)sqrt(x * 1.0) + 1; fo...
分类:
其他好文 时间:
2014-07-23 16:26:41
阅读次数:
218
Summation of Four Primes
Input: standard input
Output: standard output
Time Limit: 4 seconds
Euler proved in one of his classic theorems that prime numbers are infinite in number. But can every nu...
分类:
其他好文 时间:
2014-07-17 21:05:16
阅读次数:
299
145是个奇怪的数字,因为1!+ 4! + 5! = 1 + 24 + 120 = 145。
请求出能表示成其每位数的阶乘的和的所有数的和。
请注意:由于1! = 1和2! = 2不是和,故它们并不包括在内。
---------------------------------------------------
原来0的阶乘是1。。。。我弱智了。。。
粗略的运算一下数据范围,发现不会超过...
分类:
其他好文 时间:
2014-07-10 17:17:49
阅读次数:
170
题目如下:
Play on Words
Some of the secret doorscontain a very interesting word puzzle. The team of archaeologists has tosolve it to open that doors. Because there is no other way to open the doors,...
分类:
其他好文 时间:
2014-07-06 12:12:36
阅读次数:
221
hdu2824 The Euler function(欧拉函数个数)...
分类:
其他好文 时间:
2014-07-03 17:42:32
阅读次数:
209