代码拉取完成,页面将自动刷新
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
//输入
int n;
cin >>n;
while(n--)
{
int a;
cin >> a;
int res = a;
for(int i = 2; i <= a/i;i++)
if(a % i == 0) //i 是 a 的一个质因子
{
//公式放进来
//N x(1- 1/p1)x(1-1/p2)x...x
res = res /i * (i-1);
//用循环把质因子剔干净
while(a % i == 0) a/= i;
}
//如果a大于1,且有没有在if里执行,说明它是就是一个质数,直接处理它
if(a > 1) res = res / a * (a-1);
//res就是欧拉函数的值
cout << res << endl;
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。