当前位置:网站首页>欧拉函数
欧拉函数
2022-07-04 17:59:00 【相思明月楼】
#include <iostream>
#include <cstdio>
using namespace std;
const int Max = 100000;
int euler[Max];
void Init(){
euler[1] = 1;
for(int i = 2; i < Max; i++) {
euler[i]=i;
}
for(int i = 2; i < Max; i++) {
if(euler[i] == i) {
for(int j = i; j < Max; j += i) {
euler[j]=euler[j]/i*(i-1);
}
}
}
}
int main() {
int n;
Init();
while(scanf("%d", &n) != EOF) {
printf("%d\n", euler[n]);
}
return 0;
}
边栏推荐
猜你喜欢
随机推荐
数组中的第K个最大元素
FPGA时序约束分享01_四大步骤简述
Oracle with as ora-00903: invalid table name multi report error
To sort out messy header files, I use include what you use
Lm10 cosine wave homeopathic grid strategy
反射(一)
Is the securities account opened by qiniu safe?
英特尔集成光电研究最新进展推动共封装光学和光互连技术进步
Go microservice (II) - detailed introduction to protobuf
大佬们,求助一下,我用mysql cdc 2.2.1(flink 1.14.5)写入kafka,设置
基于NCF的多模块协同实例
Online sql to excel (xls/xlsx) tool
Leetcode ransom letter C # answer
Don't just learn Oracle and MySQL!
性能优化之关键渲染路径
函数式接口
Is it safe to open an account at Great Wall Securities? How to open an account when buying stocks
牛客小白月赛7 F题
The 15th youth informatics competition in Shushan District in 2019
Stream流