Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define int long long
- #define f first
- #define s second
- struct ss
- {
- int x, y, r;
- };
- int dist (ss a, ss b)
- {
- return sqrt ((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
- }
- void solve (int a, int b)
- {
- int ca = a, cb = b;
- if (a == 0 || b == 0)
- {
- cout << a << ' ' << b;
- exit(0);
- }
- if (a >= 2 * b)
- {
- a = a % (2 * b);
- }
- if (a == 0 || b == 0)
- {
- cout << a << ' ' << b;
- exit(0);
- }
- if (b >= 2 * a)
- {
- b = b % (2 * a);
- }
- if (ca == a && cb == b)
- {
- cout << a << " " << b;
- exit(0);
- }
- solve(a, b);
- }
- main()
- {
- ios::sync_with_stdio(false);
- int a, b;
- cin >> a >> b;
- solve(a, b);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement