Problem J
Perfect Squares
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,
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
Input contains a single integer
Output
If
If
Sample Input 1 | Sample Output 1 |
---|---|
22 |
3 3 2 |
Sample Input 2 | Sample Output 2 |
---|---|
23 |
-1 |
Sample Input 3 | Sample Output 3 |
---|---|
999999999989 |
471545 0 881842 |