Problem D
A Day in Math-land
Input: Standard Input
Output: Standard Output
X and Y are two integer numbers and X>=Y.
The values of X and Y fits in 16-bit signed integer. When
the summation of these two numbers is multiplied with Y we get P
and when the absolute value of the subtraction of these two numbers is
multiplied with X we get Q. Given the value of P and Q
you must find the value of X and Y.
Input
The first line of the input file contains an integer N (N<=75000) that denotes how many lines of inputs are there. Each of the next N lines contains two integers which denotes the values P and Q respectively, here |P|<2^31, |Q|<2^31.
Output
For each line of input except the first one produce
exactly two lines of output. The first line contains the serial of output and
the next one contains possible values of X and Y (One pair of values in each line). If there is more than
one solution print the pair with smaller X value. When the given values of P and Q is impossible for any integer value of X and Y print the line “Impossible.” instead.
3 160 48 200 100 300 200 |
Case
1: 12
8 Case
2: Impossible. Case
3: 20
10 |
Problemsetter: Shahriar Manzoor