当前位置:网站首页>数学知识:欧拉函数—欧拉函数
数学知识:欧拉函数—欧拉函数
2022-06-23 07:01:00 【奋斗吧!骚年!】
题目:AcWing 873. 欧拉函数
给定 n 个正整数 ai,请你求出每个数的欧拉函数。
欧拉函数的定义
1∼N 中与 N 互质的数的个数被称为欧拉函数,记为 ϕ(N)。
若在算数基本定理中,N=p1a1p2a2…pmam,则:
ϕ(N) = N×(p1−1)/p1×(p2−1)/p2×…×(pm−1)/pm
输入格式
第一行包含整数 n。
接下来 n 行,每行包含一个正整数 ai。
输出格式
输出共 n 行,每行输出一个正整数 ai 的欧拉函数。
数据范围
1≤n≤100,
1≤ai≤2×109
输入样例:
3
3
6
8
输出样例:
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;
}
边栏推荐
- [深度学习][原创]如何不用yolov5权重或者模型进行目标检测和绘制map等参数图
- Product axure9 (English version), prototype design and production pull-down secondary menu
- U-Net: Convolutional Networks for Biomedical Image Segmentation
- 一篇文章学会er图绘制
- 【AI实战】机器学习数据处理之数据归一化、标准化
- 基于51单片机的温度检测监测报警系统设计
- Download the OSS file and modify the file name
- The Sandbox 与《足球小将》达成合作,将流行的足球漫画及动画带入元宇宙
- Intelligence Education - how to merge codes when code conflicts occur in multi person collaborative development?
- Chain tour airship development farmers' world chain tour development land chain tour development
猜你喜欢

How to quickly and gracefully download large files from Google cloud disk (II)

NTU-RGBD数据集下载及数据格式解析

一篇文章学会er图绘制

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

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

Ntu-rgbd data set download and data format analysis

Cirium has gradually become the standard for airlines' carbon dioxide emission reporting

MySQL (11) - sorting out MySQL interview questions

How MySQL converts a date to a number

MySQL (IV) - MySQL storage engine
随机推荐
Ntu-rgbd data set download and data format analysis
‘latin-1‘ codec can‘t encode characters in position 103-115: Body (‘一串中文‘) is not valid Latin-1
Heterogeneous transaction scenario interaction process and consistency assurance
Cirium has gradually become the standard for airlines' carbon dioxide emission reporting
[deep learning] [original] how to detect targets and draw map and other parameter maps without yolov5 weights or models
在线文本过滤小于指定长度工具
Hcip Road
Console Application
职场必备的30套报表模板,满足95%的报表需求,一键套用无需代码
【Kubernetes】Kubernetes各大版本的最新版本下载地址
Realization of rolling broadcast effect
Sstable details
What is the experience of being a data product manager in the financial industry
[深度学习][原创]如何不用yolov5权重或者模型进行目标检测和绘制map等参数图
Spock constraint - call frequency / target / method parameters
Both are hard disk partitions. What is the difference between C disk and D disk?
Focusing on the industry, enabling customers | release of solutions for the five industries of the cloud container cloud product family
在线JSON转CSharp(C#)Class工具
3DMAX plug-in development environment configuration and fileexport and utilities template testing
Nacos adapts to oracle11g- modify the source code of Nacos