Advertisement
Guest User

Untitled

a guest
Oct 19th, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int Ne = 10000000000;
  6. bool kor (int n)
  7. {
  8. for(int i = 0; i*i <= n; i ++)
  9. {
  10. if (i * i == n)return false;
  11. }
  12. return true;
  13. }
  14. int dil (int n) {
  15. int result = n;
  16. for(int i = 0; i < n; i ++)
  17. {
  18. if (kor(i)) result --;
  19. }
  20. result --;
  21. return result;
  22. }
  23. int phi (int n) {
  24. int result = n;
  25. for (int i=2; i*i<=n; ++i)
  26. if (n % i == 0) {
  27. while (n % i == 0)
  28. n /= i;
  29. result -= result / i;
  30. }
  31. if (n > 1)
  32. result -= result / n;
  33. return result;
  34. }
  35.  
  36. int main()
  37. {
  38. int n;
  39. for (int i = 0; i < Ne; i++)
  40. {
  41. cin >> n;
  42. if(n == 0) return 0;
  43. cout << phi(n) << ' ' << dil(n) << endl;
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement