Advertisement
Guest User

Untitled

a guest
May 27th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. //10812 - Beat the Spread!
  2. import java.util.*;
  3. public class HW11_3A617100_10812 {
  4.  
  5. public static void main(String[] args) {
  6. Scanner sc = new Scanner (System.in);
  7. int data = sc.nextInt();//幾筆
  8. for(int i = 0 ; i < data ; i++) {
  9. int sum = sc.nextInt();//分數總和
  10. int dif = sc.nextInt();//分數差
  11. int a,b;//ans
  12. if(sum%2==0 & dif%2 ==0 & sum>dif ) {
  13. //a+b=sum a-b=dif 2a=sum+dif
  14. a = (sum+dif)/2;
  15. b = sum - a;
  16. System.out.print(a+" "+b);
  17. }else {
  18. System.out.print("impossible");
  19. }
  20. }
  21. }
  22.  
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement