#P17348. [ECNA 2025] How Many Balls?
[ECNA 2025] How Many Balls?
Problem Description
If a bag contains red balls and green balls and two balls are drawn at random, the probability of getting one ball of each color is $$P(r, g) = \frac{2rg}{(r+g)(r + g - 1)}$$
Write a program which takes as input a rational number in lowest terms and determines whether there is a number and a for which .
Input Format
The only line of input contains two space-separated positive integers () and (). These two integers are guaranteed to be relatively prime.
Output Format
If there is a solution, print the two positive integers and satisfying the conditions above, separated by a space. If there are multiple solutions, output the one with the smallest value. For any value, there is at most one value (), which solves . If there is no solution with , print the word impossible.
12 25
9 16
8 25
impossible