Saleh127

UVA 11064

Jul 6th, 2020
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define test int t; cin>>t; while (t--)
  4. #define ll long long int
  5. #define fellow_junior ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  6. ll phi(ll a)
  7. {
  8.  
  9. ll ans=a;
  10. for(ll i=2;i<=sqrt(a);i++)
  11. {
  12. if(a%i==0)
  13. {
  14. while(a%i==0)
  15. {
  16. a/=i;
  17. }
  18. ans-=(ans/i);
  19. }
  20. }
  21. if(a>1) ans-=(ans/a);
  22. return ans;
  23. }
  24. ll fact(ll x)
  25. {
  26. ll f=1,i;
  27. for(i=2;i<sqrt(x);i++)
  28. {
  29. if(x%i==0)
  30. {
  31. f+=2;
  32. }
  33. }
  34. if(i*i==x) f++;
  35. return f;
  36. }
  37. int main()
  38. {
  39. fellow_junior
  40. ll c;
  41. while(cin>>c)
  42. {
  43. if(c<=1)
  44. {
  45. cout<<0<<endl;
  46. continue;
  47. }
  48. cout<<c-phi(c)-fact(c)<<endl;
  49. }
  50. return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment