Cosine
You are given two rational numbers x and y.
Find a non-degenerate triangle with integer side lengths such that the cosine of one angle is x and the cosine of another is y, and print its side lengths.
Input
The four lines contain four integers, one per line: P, Q, U and V (-10^9
≤ P, U ≤ 10^9
, 1 ≤ Q, V ≤ 10^9
). These integers define x and y as follows: x = P / Q, y = U / V.
Output
If such a non-degenerate triangle exists, print three integers on the only line of output: its side lengths in non-descending order. The numbers should be coprime, that is, the greatest common divisor of these three integers should be equal to 1. If there are multiple possible answers, print any one of them.
If such a non-degenerate triangle does not exist, print one number -1 on the only line of output.