Hello. I am new to this site so please forgive any newbie mistakes I made, but why is the compiler showing me “Wrong Answer”, even though my code is right. What might be wrong?
Here is my code:
#include<stdio.h>
int main()
{
int T,M,B;
scanf("%d",&T);
while(T--)
{
scanf("%d %d",&M,&B);
while(B > 0)
{
if(M == B)
break;
M = (M > B)?(M-B):((B = (B-M))+(2*M));
}
printf("%d\n", (M+B));
}
return 0;
}
```
*Note:* Before modifying to this, I used if-else but it was showing Time Limit Exceed. And this code runs fine on my gcc compiler (version same as in codechef).