1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
import java.util.Scanner; /** * UVA10812 */ public class UVA10812 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int time = sc.nextInt(); for (int i = 0; i < time; i++) { int S = sc.nextInt(), D = sc.nextInt(); int n1 = 0, n2 = 0; n1 = S + D; if (n1 % 2 != 0) System.out.println("impossible"); else { n1 /= 2; n2 = S - n1; if (n1 < 0 || n2 < 0) System.out.println("impossible"); else System.out.printf("%d %d\r\n", n1, n2); } } sc.close(); } } |