Perfect Squares
시간 제한1초메모리 제한2048 MB
n이 10^12 이하로 주어질 때 x^2+y^2+z^2=n인 정수 x, y, z를 찾고, 4^a(8b+7) 꼴이면 -1을 출력한다.
문제
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, only requires three perfect squares: .
You share your observations with a mathematician friend, who rattles off the following perfect squares facts:
- An odd prime can be written as the sum of two squares if and only if .
- If two positive integers and can be written as the sum of two squares, then so can their product .
- Every positive integer can be written as the sum of three perfect squares, unless it is of the form , where and are some non-negative integers.
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 ().
출력
If can be expressed as the sum of three squares, output three integers , , and . Your answer will be judged correct if and . If there are multiple valid choices for , , and you may output any of them. You must output exactly three integers, even if can be expressed as the sum of two or fewer squares.
If cannot be expressed as the sum of three squares, output and no further output.