Advertisement
aryobarzan

RSH1

Jun 7th, 2011
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.40 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. int gcd(int a,int b)
  6. {
  7.     if(a<b)
  8.         return gcd(b,a);
  9.     if(a%b==0)
  10.         return b;
  11.     else return gcd(b,a%b);
  12. }
  13.  
  14. int phi(int x)
  15. {
  16.     int ans=0;
  17.     for(int i=1;i<=x;++i)
  18.     {
  19.         if(gcd(x,i)==1)
  20.             ans++;
  21.     }
  22.     return ans;
  23. }
  24.  
  25. int main()
  26. {
  27.     int ans=0;
  28.     for(int i=1;i<1e4;++i)
  29.         ans+=(phi(i)>=phi(2*i+1));
  30.     cout<<ans<<endl;
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement