| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 | 2048 MB | 189 | 46 | 36 | 28.346% |
A famous theorem in number theory states that every positive integer can be written as the sum of four perfect squares. You have noticed, though, that usually fewer squares are enough. For example, 27ドル$ only requires three perfect squares: 27ドル = 5^2 + 1^2 + 1^2$.
You share your observations with a mathematician friend, who rattles off the following perfect squares facts:
This last fact about sums of three squares intrigues you, and so you would like to write a program that verifies the claim is true by producing the actual squares.
Input contains a single integer $n$ (1ドル ≤ n ≤ 10^{12}$).
If $n$ can be expressed as the sum of three squares, output three integers $x,ドル $y,ドル and $z$. Your answer will be judged correct if 0ドル ≤ x, y, z ≤ \sqrt{n}$ and $n = x^2 +y^2 +z^2$. If there are multiple valid choices for $x,ドル $y,ドル and $z$ you may output any of them. You must output exactly three integers, even if $n$ can be expressed as the sum of two or fewer squares.
If $n$ cannot be expressed as the sum of three squares, output $-1$ and no further output.
22
3 3 2
23
-1
999999999989
471545 0 881842