The Euler function
2869 ワード
Link:http://acm.hdu.edu.cn/showproblem.php?pid=2824
The Euler function
Time Limit:2000/1000 MS(Java/Others) メモリLimit:32768/32768 K(Java/Others)Total Submission(s):3889 Acceepted Submission(s):1613
Problem Description
The Euler function phi is_importent kind of function in number theory,(n)represents the amount of the numbers which are and copreme to n,and this function hant_b a lot of beautifunction+Heracteristies.Heckares.com.
Input
The re are several test cases.Each line has two integers a,b(2)
Output
Output the result of(a)+(a+1)+……+(b)
Sample Input
Sample Output
ソurce
2009 Multi-University Training Conteest 1-Host by TJU
大体:a~b段のオーラの値と、篩法のオーラの関数を使います.
フィルタ:1)nが素数なら、φ(n)=n-1
2)m,nが互質であれば、φ(n*m)=φ(n)*φ(m)
コアはm%p==0:
f(m*p) = f(m) * p;//f(m)の中ですから、pです.
そうでないと:
f(m*p) = f(m) * (p-1)
Euler関数は積関数なのでです.
上の二つの式を総合すれば、核心の導出式がどうやって得られますか?
[cpp] view plin copy
ヽoo.ツ.......................................................... ヽoo.ツ.......................................................... 〹include using namespace std; typedef __int 64 INT; 同前 N 30000 1 要点 preme[216818],phi[N]; ブック a[N] void isuple me() { 要点 i,j,k k=0; for(i=2;i<N;i+) { if(!a[i]) { price[k+]=i phi[i]=i-1; } for(j=0;j<k&i*preme[j]<N;j+) { a[price[j]*i==1 if(i%preme[j]) phi[i*preme[j]=phi[i]*(preme[j]-1); else { phi[i*preme[j]=phi[i]*preme[j] break; } } } ) 要点 main() { //freopen(「c in.txt」「r」、stdin) //freopen(「myout 5.txt」、「w」、stdout); 要点 a,b,i INT sum; isuple me() while(cin>>a>>b) { sum=0 for(i=a;i==b;i+) sum+=phi[i]; printf(「%I 64 d」、sum) } //printf(「%lfMS」、(double)clock()/CLOCKScuuPERuSEC); return 0; )
The Euler function
Time Limit:2000/1000 MS(Java/Others) メモリLimit:32768/32768 K(Java/Others)Total Submission(s):3889 Acceepted Submission(s):1613
Problem Description
The Euler function phi is_importent kind of function in number theory,(n)represents the amount of the numbers which are and copreme to n,and this function hant_b a lot of beautifunction+Heracteristies.Heckares.com.
Input
The re are several test cases.Each line has two integers a,b(2)
Output
Output the result of(a)+(a+1)+……+(b)
Sample Input
3 100
Sample Output
3042
ソurce
2009 Multi-University Training Conteest 1-Host by TJU
大体:a~b段のオーラの値と、篩法のオーラの関数を使います.
フィルタ:1)nが素数なら、φ(n)=n-1
2)m,nが互質であれば、φ(n*m)=φ(n)*φ(m)
コアはm%p==0:
f(m*p) = f(m) * p;//f(m)の中ですから、pです.
そうでないと:
f(m*p) = f(m) * (p-1)
Euler関数は積関数なのでです.
上の二つの式を総合すれば、核心の導出式がどうやって得られますか?
[cpp] view plin copy
ヽoo.ツ.......................................................... ヽoo.ツ.......................................................... 〹include