Advertisement
Guest User

Untitled

a guest
Nov 13th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. #define int long long
  6. #define f first
  7. #define s second
  8.  
  9. struct ss
  10. {
  11. int x, y, r;
  12. };
  13.  
  14. int dist (ss a, ss b)
  15. {
  16. return sqrt ((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
  17. }
  18.  
  19. void solve (int a, int b)
  20. {
  21. int ca = a, cb = b;
  22. if (a == 0 || b == 0)
  23. {
  24. cout << a << ' ' << b;
  25. exit(0);
  26. }
  27. if (a >= 2 * b)
  28. {
  29. a = a % (2 * b);
  30. }
  31. if (a == 0 || b == 0)
  32. {
  33. cout << a << ' ' << b;
  34. exit(0);
  35. }
  36. if (b >= 2 * a)
  37. {
  38. b = b % (2 * a);
  39. }
  40. if (ca == a && cb == b)
  41. {
  42. cout << a << " " << b;
  43. exit(0);
  44. }
  45. solve(a, b);
  46. }
  47.  
  48. main()
  49. {
  50. ios::sync_with_stdio(false);
  51. int a, b;
  52. cin >> a >> b;
  53. solve(a, b);
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement