1136 尤拉函式(板子)

2021-09-26 16:09:28 字數 436 閱讀 9614

對正整數n,尤拉函式是少於或等於n的數中與n互質的數的數目。此函式以其首名研究者尤拉命名,它又稱為euler』s totient function、φ函式、尤拉商數等。例如:φ(8) = 4(phi(8) = 4),因為1,3,5,7均和8互質。

輸入輸入乙個數n。(2 <= n <= 10^9)

輸出輸出phi(n)。

輸入樣例

8輸出樣例

4尤拉函式

#includeusing namespace std;

int euler(int n)//少於或等於n的數中與n互質的數的數目

if(n>1) res-=res/n;

return res; }

//對於乙個數,與其互質的數的總和是euler(n)*n/2

int main()

尤拉函式板子

求單個ll eular ll n if n 1 ans ans n n 1 return ans 多個用篩 特性 1.若a為質數,phi a a 1 2.若a為質數,b mod a 0,phi a b phi b a 3.若a,b互質,phi a b phi a phi b 當a為質數時,if b ...

51nod1136 尤拉函式

對正整數n,尤拉函式是少於或等於n的數中與n互質的數的數目。此函式以其首名研究者尤拉命名,它又稱為euler s totient function 函式 尤拉商數等。例如 8 4 phi 8 4 因為1,3,5,7均和8互質。input 輸入乙個數n。2 n 10 9 output 輸出phi n ...

51nod 1136 尤拉函式

對正整數n,尤拉函式是少於或等於n的數中與n互質的數的數目。此函式以其首名研究者尤拉命名,它又稱為euler s totient function 函式 尤拉商數等。例如 8 4 phi 8 4 因為1,3,5,7均和8互質。input 輸入乙個數n。2 n 10 9 output 輸出phi n ...