OMG this was a bad mistake , thanks for the help.
Why 7 27 output is 2 instead of 1?
gcd(7, 28) is 7 > 1
It should be 1 - where are you seeing that the output should be 2?
sorry my bad 
though used the same approach but could not get ac. can any one explain what was my mistake?
my code - Fj10CB - Online C++0x Compiler & Debugging Tool - Ideone.com
It fails on the test input:
1
5 21
Try this
1
3 5
Output should be 1 but your code outputs 2
but my code is giving ans 2 for 5 and 21. isn’t correct?
No: 5+1=6, and \gcd(6,21)=3.
Please Help. Why is this giving WA. Cant think of any case it will fail.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
int t;cin>>t;
while(t–)
{
ll x,y,c=0;cin>>x>>y;
while(__gcd(x,y)==1)
{
if(x<y)swap(x,y);
if(x%2==0)y++;
else x++;
c++;
}
cout<<c<<endl;
}
}
Maybe stop running sieve()?
17 29 becomes 18 and 30 after 2 operations then gcd(18,30)>1… We can change both values but in different operation.
Didnt’t worked for me…still giving me TLE…pls help
For god sake, watch your code - the indentation sucks. Provide a cleaner code. It becomes easy to find out where it went wrong.
https://www.codechef.com/viewsolution/49222720
Why my solution giving WA ? Giving correct answers when testing for all combinations of even and odd numbers.
You didn’t test all combinations.
Try this test case:
Input
1
3 9
Expected Output
0
Your Output
2
It should be mentioned in the question that we can change both the numbers.
It is clearly written.