Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void solve() {
- ll x, y; cin >> x >> y;
- ll mn = min(x, y);
- ll mx = max(x, y);
- ll ans1 = INT_MAX, ans2 = INT_MAX, ans3 = INT_MAX;
- if (x % 2 == 0 and y % 2 == 0) {
- cout << 0;
- return;
- }
- // else if (x == 1 or y == 1)
- // { cout << 1;
- // return;
- // }
- else if ( x == y) {
- cout << 0;
- return;
- }
- else {
- if (__gcd(x + 1, y) > 1) {
- ans1 = 1 ;
- if (__gcd(x + 1, y) <= 1)
- ans1++;
- }
- if (__gcd(y + 1, x) > 1) {
- ans2 = 1;
- if (__gcd(y + 1, x) <= 1)
- ans2++;
- }
- if (__gcd(x + 1, y + 1) > 1) {
- ans3 = 2;
- }
- }
- cout << min({ans1, ans2, ans3});
- // error(no);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement