当前位置:网站首页>Mathematical knowledge: Euler function - Euler function
Mathematical knowledge: Euler function - Euler function
2022-06-23 07:45:00 【Fight! Sao Nian!】
subject :AcWing 873. Euler function
Given n A positive integer ai, Please find the Euler function of each number .
The definition of Euler function
1∼N China and N The number of Coprime numbers is called Euler function , Write it down as ϕ(N).
If in the basic theorem of arithmetic ,N=p1a1p2a2…pmam, be :
ϕ(N) = N×(p1−1)/p1×(p2−1)/p2×…×(pm−1)/pm
Input format
The first line contains integers n.
Next n That's ok , Each line contains a positive integer ai.
Output format
The output, n That's ok , Each line outputs a positive integer ai The Euler function of .
Data range
1≤n≤100,
1≤ai≤2×109
sample input :
3
3
6
8
sample output :
2
2
4
#include <iostream>
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)
{
res=res/i*(i-1);
while(a%i==0)a/=i;
}
if(a>1)res=res/a*(a-1);
cout<<res<<endl;
}
return 0;
}
边栏推荐
- Product axure9 (English version), prototype design background dynamic secondary menu display content
- HCIP之路
- Which company would like to buy serious illness insurance in 2022?
- 在线文本过滤小于指定长度工具
- [2022 graduation season] from graduation to transition to the workplace
- HCIP之路第八次实验
- [veusz] import 2D data in CSV
- Online text filter less than specified length tool
- 30 sets of report templates necessary for the workplace, meeting 95% of the report needs, and no code is required for one click application
- 论文写作之WPS安装Mathtype插件编写数学公式
猜你喜欢

Nacos adapts to oracle11g- modify the source code of Nacos

HCIP之路第八次实验

传智教育 | 项目发布前如何打tag标签及标签命名规范

JS to determine the added and decreased elements of two arrays

The road to hcip MPLS

启动appium

论文写作之WPS安装Mathtype插件编写数学公式
three. Solution to stripe shadow and grid shadow in JS
![[深度学习][原创]如何不用yolov5权重或者模型进行目标检测和绘制map等参数图](/img/f3/ff14cb5439a24e26f977e5f0d15785.png)
[深度学习][原创]如何不用yolov5权重或者模型进行目标检测和绘制map等参数图

3dmax插件开发环境配置及FileExport和Utilities模板测试
随机推荐
快速排序 + 冒泡排序 + 插入排序 + 選擇排序
Principle of skip table
小爱音箱连接网络异常解决办法
[cloud computing event] vocational skill competition -- container development example pig rapid development framework
HCIP之路
MySQL (IV) - MySQL storage engine
EXCEL VBA 入门与实用例子
Wechat multiplayer chat and Roulette Games (websocket Implementation)
MySQL慢查询记录
[Laoke] how should ordinary people learn technology?
[veusz] import 2D data in CSV
unity 音频可视化方案
快速删除代码里面的node_modules
Detailed explanation of redis persistence, master-slave and sentry architecture
mysql中多表视图性能疑惑
Sstable details
MySQL (VIII) - explain
帆软堆积图显示占比
Difference between char and varchar
Realization of rolling broadcast effect