> 其他 >
编程ACM的一道题
There are several test cases.For each test case,standard input contains a line with n
人气:434 ℃ 时间:2020-07-31 19:13:17
解答
There are several test cases.
多组测试数所
For each test case, standard input contains a line with n Given n, a positive integer, how many positive integers less than n are relatively prime to n? Two integers a and b are relatively prime if there are no integers x > 1, y > 0, z > 0 such that a = xy and b = xz.InputThere are several test cases. For each test case, standard input contains a line with n <= 1,000,000,000. A line containing 0 follows the last case.是欧拉函数可以百度一下int eular(int n){int ret=1,i;for(i=2;i*i<=n;i++)if(n%i==0){n/=i,ret*=i-1;while(n%i==0)n/=i,ret*=i;}if(n>1)ret*=n-1;return ret;}
推荐
猜你喜欢
© 2024 79432.Com All Rights Reserved.
电脑版|手机版