How Many Balls?
시간 제한: 1000ms메모리 제한: 2048MB출처: ICPC ECNA 2025-2026BOJ 35379
문제
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
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
출력
9 16
예제 2
입력
8 25
출력
impossible
코드를 제출하려면 로그인하세요.