样例过了但WA
查看原帖
样例过了但WA
1166678
sunnyboy1楼主2025/1/30 21:00

提交记录

#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
ull t,x;
ull euler_phi(ull n){
	ull ans = n;
	for(ull i = 2; i * i <= n; i++){
		if(n % i == 0){
			ans = ans / i * (i - 1);
			while(n % i == 0) n /= i;
		}
	}
	if(n > 1) ans = ans / n * (n - 1);
	else if(n == 1) return 0;
	return ans;
}
int main(){
    while(cin >> x, x) cout << euler_phi(x) << endl;
    return 0;
}
2025/1/30 21:00
加载中...