You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
684 B
31 lines
684 B
#include <bits/stdc++.h>
|
|
|
|
using namespace std;
|
|
|
|
int gcd(int a, int b) {
|
|
return b ? gcd(b, a % b) : a;
|
|
}
|
|
|
|
// 欧拉函数暴力解法,这种办法太慢,才会想办法进行优化
|
|
// 欧拉函数的精讲
|
|
// https://www.bilibili.com/video/BV157411w7pm?p=1
|
|
int main() {
|
|
//输入+输出重定向
|
|
freopen("../AcWing/N11/PHILow.txt", "r", stdin);
|
|
int n;
|
|
scanf("%d", &n);
|
|
//1是欧拉函数的第一个
|
|
printf("%d ",1);
|
|
int ans = 1;
|
|
for (int i = 2; i < n; i++) {
|
|
if (gcd(i, n) == 1) {
|
|
printf("%d ",i);
|
|
ans++;
|
|
}
|
|
}
|
|
printf("\n");
|
|
printf("%d", ans);
|
|
//关闭文件
|
|
fclose(stdin);
|
|
return 0;
|
|
} |