hdu2824 2010.2.26
来源:互联网 发布:浙江网络诈骗立案标准 编辑:程序博客网 时间:2024/05/22 00:18
hdu2824 2010.2.26
hdu2824 欧拉函数
The Euler function
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 293 Accepted Submission(s): 100
Problem Description
The Euler function phi is an important kindof function in number theory, (n) represents the amount of the numbers whichare smaller than n and coprime to n, and this function has a lot of beautifulcharacteristics. Here comes a very easy question: suppose you are given a, b,try to calculate (a)+ (a+1)+....+ (b)
Input
There are several test cases. Each line hastwo integers a, b (2<a<b<3000000).
Output
Output the result of (a)+ (a+1)+....+ (b)
Sample Input
3 100
Sample Output
3042
Source
2009 Multi-University Training Contest 1 -Host by TJU
欧拉函数
在数论,对正整数n,欧拉函数是少于或等于n的数中与n互质的数的数目。此函数以其首名研究者欧拉命名,它又称为Euler's totient function、φ函数、欧拉商数等。
例如φ(8)=4,因为1,3,5,7均和8互质。
从欧拉函数引伸出来在环论方面的事实和拉格朗日定理构成了欧拉定理的证明。
φ函数的值
φ(1)=1(唯一和1互质的数就是1本身)。
若n是质数p的k次幂,φ(n)=p^k-p^(k-1)=(p-1)p^(k-1),因为除了p的倍数外,其他数都跟n互质。
欧拉函数是积性函数——若m,n互质,φ(mn)=φ(m)φ(n)。
证明:设A, B, C是跟m, n, mn互质的数的集,据中国剩余定理,A*B和C可建立一一对应的关系。因此φ(n)的值使用算术基本定理便知,
若
n= ∏p^(α(下标p))
p|n
则φ(n)=∏(p-1)p^(α(下标p)-1)=n∏(1-1/p)
p|n p|n
例如φ(72)=φ(2^3×3^2)=(2-1)2^(3-1)×(3-1)3^(2-1)=24
与欧拉定理、费马小定理的关系
对任何两个互质的正整数a, m, m>=2有
a^φ(m)≡1(mod m)
即欧拉定理
当m是质数p时,此式则为:
a^(p-1)≡1(mod m)
即费马小定理。
欧拉函数的编程实现:
利用欧拉函数和它本身不同质因数的关系,用筛法计算出某个范围内所有数的欧拉函数值。
欧拉函数和它本身不同质因数的关系:欧拉函数ψ(N)=N{∏p|N}(1-1/p)。(P是数N的质因数)
如:
ψ(10)=10×(1-1/2)×(1-1/5)=4;
ψ(30)=30×(1-1/2)×(1-1/3)×(1-1/5)=8;
ψ(49)=49×(1-1/7)=42。
Recommend
gaojie
#include <stdio.h>#include <string.h>#define N 3000000+10__int64 phi[N];void main(){ __int64 i,j; phi[1] = 1; for(i=2;i<=N;i++) if(!phi[i]) { for(j=i; j<=N; j+=i) { if (!phi[j]) phi[j] = j; phi[j] = phi[j] / i * (i-1); } }int a,b;while (scanf("%d %d",&a,&b)!=EOF){__int64 ans=0;int i;for(i=a;i<=b;i++)ans+=phi[i];printf("%I64d\n",ans);} }
- hdu2824 2010.2.26
- hdu2824
- hdu2824 快速求欧拉函数
- hdu2824-The Euler function
- hdu2824-The Euler function
- hdu2824:The Euler function
- hdu2824 The Euler function
- hdu2824(欧拉函数)
- hdu2824(the Euler Function)
- HDU2824 欧拉函数
- hdu2824筛选法欧拉函数+求和
- hdu2824欧拉函数模板
- HDU2824【欧拉函数性质】
- 欧拉函数(hdu2824)
- HDU_Steps7.2 HDU2824 HDU1787 HDU1757 HDU3579 HDU1299
- hdu2824 The Euler function (欧拉函数)
- hdu2824 The Euler function 欧拉函数
- hdu2824(简单欧拉函数)
- UML:统一建模语言
- 使用SecureCRT在windows与linux间传输文件
- hdu2817 2010.2.25
- [Unity3D]Window Phone代码通信
- poj1001 2010.2.25
- hdu2824 2010.2.26
- L2 正则化
- poj2926 2010.2.26
- Java设计模式(十八)----命令模式
- hdu3220 2010.3.1
- HDU 3639 Hawk-and-Chicken(强连通分量+缩点)
- XStream的使用(2)——集合形式的 JavaBean 转化为 xml
- HYSBZ/BZOJ 1037 [ZJOI2008] 生日聚会Party - dp
- Etaoin Shrdlu 2010.3.2