My issue
Why my code is failing?
My code
#include <stdio.h>
#include<stdlib.h>
int main() {
// your code goes here
int t;
scanf("%d", & t);
while (t--)
{
int x, y;
scanf("%d %d", & x, & y);
if (y > x)
{
int temp = y;
y = x;
x = temp;
}
if ((x >= y) & (x % 2 == 1))
{
printf("%d\n", abs(2 * y - x));
}
else if ((x >= y) & (x % 2 == 0))
{
if (abs(2 * y - x) < abs(x / 2 - y)) printf("%d\n", abs(2 * y - x));
else printf("%d\n", abs(x / 2 - y));
}
}
}
Problem Link: Ratio By 2 Practice Coding Problem