UVA 10812 Java
import java.util.*; public class main{ public static void main(String[] args) { Scanner sc=new Scanner(System.in); int cases = sc.nextInt(); for(int i = 0; i < cases; i++) { int num1 = sc.nextInt(); int num2 = sc.nextInt(); int sum = num1 + num2; int dif = num1 - num2; if(sum < 0 || dif < 0 || sum % 2 != 0 && dif % 2 != 0) System.out.println("impossible"); else System.out.printf("%d %d\r\n", sum / 2, dif / 2); } } };
留言
張貼留言