1 条题解
-
0
根据定义,得到 为 的各个约数,所以只需要枚举约数,然后连乘就得到结果
#include <bits/stdc++.h> int main() { int n; std::cin >> n; while (n --) { int a; std::cin >> a; int res = a; // res存储最终的结果 for (int i = 2; i <= a / i; i ++) // 对数据先进行质因数分解 { if(a % i == 0) // i是a的一个约数 { res = res / i * (i - 1); // 化简之后的,相当于乘以 1-(1/i) while (a % i == 0) a /= i; // 消除这个约数i的限制,让a一直除i直到a除不尽 } } if(a > 1) res = res / a * (a - 1); std::cout << res <<std::endl; } return 0; }
- 1
信息
- ID
- 107
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 5
- 标签
- 递交数
- 23
- 已通过
- 14
- 上传者