Topic Links:
http://acm.hdu.edu.cn/showproblem.php?pid=1787
Main topic:
give you an integer n, the number of integers with a range less than n, and an integer greater than 1 for the greatest common divisor of N.
Ideas:
The typical Euler function is deformed. The Euler function φ (n) is the number of greatest common divisor that is used to find an integer less than n, and N is 1.
So the answer to this question is ans = n-φ (n)-1.
AC Code:
#include <iostream> #include <algorithm> #include <cstdio> #include <cstring>using namespace Std;int Euler (int n) { int ret = n; for (int i = 2; i*i <= n; ++i) { if (n = = = 0) { n/= i; ret = ret-ret/i; } while (n% i = = 0) n/= i; } if (n > 1) ret = ret-ret/n; return ret;} int main () { int n; while (~SCANF ("%d", &n) && N) { printf ("%d\n", N-euler (N)-1); } return 0;}
HDU1787 GCD Again "Euler function"