fork download
  1. #include <bits/stdc++.h>
  2.  
  3. #define ll long long
  4. #define el cout << '\n'
  5.  
  6. using namespace std;
  7.  
  8. ll n, ans;
  9.  
  10. int main()
  11. {
  12. ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  13. if (fopen("MATH_IS_FUN.INP", "r"))
  14. {
  15. freopen("MATH_IS_FUN.INP", "r", stdin);
  16. freopen("MATH_IS_FUN.OUT", "w", stdout);
  17. }
  18. cin >> n;
  19. ans = n > 1 ? n : 0;
  20. for (ll i = 2; i * i <= n; i++)
  21. {
  22. bool flag = 0;
  23. while (n % i == 0)
  24. {
  25. n /= i;
  26. flag = 1;
  27. }
  28. if (flag) ans -= ans/i;
  29. }
  30. if (n > 1) ans -= ans/n;
  31. cout << ans;
  32. }
Success #stdin #stdout 0.01s 5308KB
stdin
Standard input is empty
stdout
Standard output is empty