当前位置:网站首页>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;
}
边栏推荐
- Qt 使用QDomDocument读取xml文件
- 传智教育 | 多人协作开发出现代码冲突,如何合并代码?
- 数学知识:快速幂—快速幂
- C WPF additional attribute implementation interface defines decorator
- [markdown] markdown tutorial summary
- 快手350014
- The Sandbox 与《足球小将》达成合作,将流行的足球漫画及动画带入元宇宙
- Design of temperature detection and alarm system based on 51 single chip microcomputer
- mysql中多表视图性能疑惑
- MySQL transaction isolation level
猜你喜欢

职场必备的30套报表模板,满足95%的报表需求,一键套用无需代码
![[cloud computing event] vocational skill competition -- container development example pig rapid development framework](/img/4b/393b5980090330602a501867c60089.png)
[cloud computing event] vocational skill competition -- container development example pig rapid development framework

MySQL on duplicate key and PgSQL on conflict (primary key) handle primary key conflicts

链游飞船开发 农民世界链游开发 土地链游开发

利用for循环输出一个字母三角形

Qt工程报错:-1: error: Cannot run compiler ‘clang++‘. Output:mingw32-make.exe

User mode and kernel mode

HCIP之路MPLS

C WPF realizes dynamic loading of controls through binding

Wechat multiplayer chat and Roulette Games (websocket Implementation)
随机推荐
ArcMap批量删除距离较近的点
MySQL (IV) - MySQL storage engine
MySQL transaction isolation level
Design of temperature detection and alarm system based on 51 single chip microcomputer
[2022 graduation season] from graduation to transition to the workplace
Elaborate on the operation of idea
How to solve CSRF attack in laravel
MySQL (11) - sorting out MySQL interview questions
HCIP之路
How bootstrap clears floating styles
Matlab随机波动率SV、GARCH用MCMC马尔可夫链蒙特卡罗方法分析汇率时间序列
. H5 file forgets the database name and uses h5py to print
TCP fastopen is used inside the origin server to quickly return to the source
3dmax插件开发环境配置及FileExport和Utilities模板测试
MySQL (VIII) - explain
浅析 Open API 设计规范
NFS special attention to permissions
C WPF additional attribute implementation interface defines decorator
MySQL (II) - MySQL data type
Feelm joined the Carbon Disclosure Project as an initiative of Smallville to deal with climate change emergencies