#P10858. Dragon's Puzzle in The End
Dragon's Puzzle in The End
Dragon's Puzzle in The End
In Minecraft, there are three dimensions in the simple world. One of them is known as "The End" where the Ender Dragon, the final boss, resides. To defeat the dragon, you, Steve, and we must solve a puzzle posed by the dragon.
The puzzle is as follows: Given two positive integers \(x\) and \(y\), find two integers \(a\) and \(b\) such that
[ \sqrt{\frac{\operatorname{lcm}(x,y)}{\gcd(x,y)}} = a\sqrt{b} ]
and maximize \(a \cdot b\). Here, \(\gcd(a, b)\) is the greatest common divisor of \(a\) and \(b\), and \(\operatorname{lcm}(a, b)\) is the least common multiple of \(a\) and \(b)\).
Note: For any positive integers \(x,y\), let \(r = \frac{\operatorname{lcm}(x,y)}{\gcd(x,y)}\). It can be observed that for any representation \(\sqrt{r} = a\sqrt{b}\) satisfying \(a^2 \cdot b = r\), if we choose \(a=1\) then \(b=r\) and the product \(a\cdot b=r\) is maximized. Thus, the answer is to output a = 1
and b = r
where \(r = \frac{\operatorname{lcm}(x,y)}{\gcd(x,y)} = \frac{x\cdot y}{\gcd(x,y)^2}\).
inputFormat
The input consists of a single line containing two positive integers \(x\) and \(y\) (\(1 \le x, y \le 10^9\)).
outputFormat
Output two integers \(a\) and \(b\) separated by a space, representing the desired values that satisfy the equation \(\sqrt{\frac{\operatorname{lcm}(x,y)}{\gcd(x,y)}} = a\sqrt{b}\) and maximize \(a \cdot b\).
sample
3 5
1 15