| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 | 2048 MB | 218 | 48 | 38 | 27.941% |
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
ICPC > Regionals > North America > Southeast USA Regional > 2024 Southeast USA Regional Programming Contest > Division 1 J번
ICPC > Regionals > North America > Southeast USA Regional > 2024 Southeast USA Regional Programming Contest > Division 2 J번
ICPC > Regionals > North America > South Central USA Regional > 2024 South Central USA Regional Contest > Division 1 J번
ICPC > Regionals > North America > South Central USA Regional > 2024 South Central USA Regional Contest > Division 2 J번
ICPC > Regionals > North America > Mid-Atlantic Regional > 2024 Mid-Atlantic USA Regional Contest > Division 1 J번
ICPC > Regionals > North America > Mid-Atlantic Regional > 2024 Mid-Atlantic USA Regional Contest > Division 2 J번