有个坑,由于分数是非负整数,所以sum和diff同为奇或同为偶,为此WA了一次
import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
for (int i = 0; i < n; i++)
{
int sum = sc.nextInt();
int diff = sc.nextInt();
if (diff > sum)
System.out.println("impossible");
else if ((sum + diff) % 2 != 0)
System.out.println("impossible");
else
System.out
.format("%d %d\n", (sum + diff) / 2, (sum - diff) / 2);
}
}
}