当前位置:网站首页>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;
}
边栏推荐
猜你喜欢

YGG Spain subdao Ola GG officially established

Nacos adapts to oracle11g- modify the source code of Nacos

C WPF additional attribute implementation interface defines decorator

Yan's DP analysis

Product axure9 (English version), prototype design and production pull-down secondary menu

基于51单片机的温度检测监测报警系统设计

Deploy kubersphere in kubernetes

JS to determine the added and decreased elements of two arrays

20bn Jester complete dataset Download

【Veusz】导入CSV中的二维数据
随机推荐
unity转微信小程序小游戏
这道字符串反转的题目,你能想到更好的方法吗?
Design of temperature detection and alarm system based on 51 single chip microcomputer
How to quickly and gracefully download large files from Google cloud disk (II)
【星球精选】如何高效构建 Roam 与 theBrain 间细粒度双向链接?
Realization of rolling broadcast effect
G++ compilation command use
YGG Spain subdao Ola GG officially established
Product axure9 (English version), prototype design and production pull-down secondary menu
Heuristic search strategy
How MySQL converts a date to a number
浅谈ThreadLocal和InheritableThreadLocal,源码解析
帆软堆积图显示占比
Simpledateformat thread safety issues
聊聊服务治理中的路由设计
1.概率论-组合分析
Sstable details
MySQL (V) - locks and transactions
传智教育 | 多人协作开发出现代码冲突,如何合并代码?
RFID data security experiment: C # visual realization of parity check, CRC redundancy check and Hamming code check