SGU---102 欧拉函数

题目链接:

https://cn.vjudge.net/problem/SGU-102#author=0

题目大意:

求解小于等于N的且与N互质的数字有多少个

解题思路:

直接求欧拉函数即可

关于欧拉函数的知识:传送门

这里可以直接暴力,但是如果不会欧拉函数单个求,打表求的话还是看上述链接。

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 
 4 int main()
 5 {
 6     int n, ans = 0;
 7     scanf("%d", &n);
 8     for(int i = 1; i <= n; i++)
 9         if(__gcd(i, n) == 1)ans++;
10     printf("%d
", ans);
11     return 0;
12 }
原文地址:https://www.cnblogs.com/fzl194/p/9119274.html