Skip to content

Instantly share code, notes, and snippets.

@peter279k
Created December 22, 2015 02:04
Show Gist options
  • Save peter279k/1c2d1599429048826fa3 to your computer and use it in GitHub Desktop.
Save peter279k/1c2d1599429048826fa3 to your computer and use it in GitHub Desktop.
import java.util.*;
public class main{
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int numbers = input.nextInt();
for(int i=1;i<=numbers;i++) {
int x = input.nextInt();
int y = input.nextInt();
int x_add_y = x + y;
if(x_add_y % 2 != 0) {
System.out.println("impossible");
continue;
}
int x_ans = (x_add_y) / 2;
int y_ans = x - x_ans;
if(x_ans < 0 || y_ans < 0)
System.out.println("impossible");
else
System.out.println(x_ans + " " + y_ans);
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment