0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-09-16 20:25:24 +00:00
Baoshuo Ren 2021-09-17 19:20:45 +08:00 committed by Baoshuo Ren
parent 13451e4757
commit cf82beddae
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

26
AcWing/873/873.cpp Normal file
View File

@ -0,0 +1,26 @@
#include <bits/stdc++.h>
using namespace std;
int n, x;
int phi(int x) {
int res = x;
for (int i = 2; i * i <= x; i++) {
if (x % i == 0) {
res = res / i * (i - 1);
while (x % i == 0) x /= i;
}
}
if (x > 1) res = res / x * (x - 1);
return res;
}
int main() {
cin >> n;
while (n--) {
cin >> x;
cout << phi(x) << endl;
}
return 0;
}