https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1753 困難度 ★ 這題在校內程式競賽有出現過 第一個數a=(和+差)/2 b=和-a
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner scn = new Scanner(System.in);
int n = scn.nextInt();
for (int i = 0; i < n; i++) {
int a = scn.nextInt(), b = scn.nextInt();
if (b > a || (b + a) / 2 - (a - (b + a) / 2) != b)
System.out.println("impossible");
else
System.out.println((b + a) / 2 + " " + (a - (b + a) / 2));
}
}
/*
題目:Q10812: Beat the Spread!
作者:1010
時間:西元 2016 年 7 月 */
}