logo AlgoBeat OnlineJudge
登录 注册

#217657. [ECNA 2025] How Many Balls?

内存限制:2048 MiB 时间限制:1000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

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 .

输入格式

The only line of input contains two space-separated positive integers () and (). These two integers are guaranteed to be relatively prime.

输出格式

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.

样例

样例输入 1

12 25

样例输出 1

9 16

样例输入 2

8 25

样例输出 2

impossible