Advertisement
Guest User

Solution B

a guest
Feb 7th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.46 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int gcd(int a, int b)
  6. {
  7.     if (b == 0)
  8.         return a;
  9.     return gcd(b, a % b);
  10. }
  11.  
  12. int main()
  13. {
  14.     double x;
  15.     cin >> x;
  16.     int n;
  17.     cin >> n;
  18.     int result = 0;
  19.     for (int i = 1; i <= n; ++i)
  20.     {
  21.         for (int j = 1; j <= n; ++j)
  22.         {
  23.             if ((double) j / (double)i <= x && gcd(j, i) == 1)
  24.                 ++result;
  25.         }
  26.     }
  27.     cout << result;
  28.     return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement