Description
解方程 x=a+b,y=a-b,求a b
Input
第一行为用例组数,每组用例包括两个整数x,y
Output
对于每组用例,输出解a,b,若不存在可行解则输出impossible
Sample Input
2
40 20
20 40
Sample Output
30 10
impossible
Solution
水题,注意a>=b
Code
#include<stdio.h>
int main()
{
int a,b,n;
scanf("%d",&n);
while(n)
{
scanf("%d%d",&a,&b);
if(a<b||(a+b)%2!=0)
printf("impossible\n");
else
printf("%d %d\n",(a+b)/2,(a-b)/2);
n--;
}
}