CHFGCD What is wrong in this?

#include <bits/stdc++.h>
using namespace std;

#define for0(i,n) for(int i=0;i<n;i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define tc(t) int t;cin >>t;while(t–)
#define ll long long int
#define pb(i) push_back(i)
#define mod 1000000007
#define line “\n”

int main() {
#ifndef ONLINE_JUDGE
freopen(“input.txt”, “r”, stdin);
freopen(“output.txt”, “w”, stdout);
#endif
int t;
cin >> t;
while (t–)
{
ll x, y;
cin >> x >> y;
if (__gcd(x, y) > 1) cout << 0 << line;
else {
if (x % 2 == 0 && y % 2 != 0) {
cout << 1 << line;
}
else if (x % 2 == 1 && y % 2 == 0) {
cout << 1 << line;
}
else if (x % 2 == 1 && y % 2 != 0) {
cout << 2 << line;
}
}
}
return 0;
}

What’s wrong in this code?
I am getting WA for this code.

check on 3 and 23

2 Likes

When two numbers are odd you are printing 2 as answer but that is not always true.Consider 15 and 17 answer will be 1 (incrementing 17 by 1 makes gcd greater than 1)

2 Likes