Question: [Python] Boastin' Red Socks You have a drawer that is full of two kinds of socks: red and black. You know that there are at

[Python] Boastin' Red Socks

You have a drawer that is full of two kinds of socks: red and black. You know that there are at least 2 socks, and not more than 50000. However, you do not know how many there actually are, nor do you know how many are red, or how many are black.

You have noticed, though, that when you reach into the drawer each morning and choose two socks to wear (in pitch darkness, so you cannot distinguish red from black), the probability that you pick two red socks is exactly [Python] Boastin' Red Socks You have a drawer that is full of, where two kinds of socks: red and black. You know that there are and at least 2 socks, and not more than 50000. However, you do.

From this, can you determine how many socks of each colour are in your drawer? There may be multiple solutions if so, pick the solution with the fewest total number of socks, but still allowing you to wear a couple of same color socks.

Input

Input consists of multiple problems, each on a separate line. Each problem consists of the integers p and q separated by a single space. You may assume that p and q will both fit into an unsigned 32-bit integer.

Input is terminated by a line consisting of two zeroes.

Output

For each problem, output a single line consisting of the number of red socks and the number of black socks in your drawer, separated by one space. If there is no solution to the problem, print impossible.

not know how many there actually are, nor do you know how

p/

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!