定义(来自WiKi):
例题:
AcWing: 873.约数之和
![](https://img-blog.csdnimg.cn/img_convert/c020d72509b8a9268719073430a03db3.png)
代码:
1 #include <iostream>
2 #include <cstring>
3 #include <cstdio>
4 #include <algorithm>
5
6 using namespace std;
7
8 typedef long long LL;
9
10 int n;
11
12 int main()
13 {
14 scanf("%d", &n);
15
16 while (n -- )
17 {
18 int x;
19 scanf("%d", &x);
20
21 LL res = x;
22 for (int i = 2; i <= x / i; i ++ )
23 if (x % i == 0)
24 {
25 while (x % i == 0) x /= i;
26 res = res * (i - 1) / i;
27 }
28
29 if (x > 1) res = res * (x - 1) / x;
30
31 printf("%d\n", res);
32 }
33
34 return 0;
35 }