Hide

Problem G
All Square Sums

Languages en is
/problems/allsquaresums/file/statement/en/img-0001.jpg
Image owned by FUNimation, Toei Animation, Fuji TV and Akira Toriyama. Edit made by TeamFourStar

You are given a non-negative integer $n$ and should print all ways to write $n$ as the sum of two integer squares.

Input

The first and only line of input contain a non-negative integer $n \leq 10^{18}$.

Output

First print the number of ways $n$ can be written as the sum of two integer squares on its own line, call this number $k$. Then print $k$ lines, each containing one way to write $n$ as the sum of two integer squares. If $x^2 + y^2 = n$ is one such way, print x^2 + y^2 = n on its own line. If $x$ or $y$ is negative it needs to be put in parentheses, see the sample input. The internal order of these lines does not matter.

Sample Input 1 Sample Output 1
52706
8
(-95)^2 + (-209)^2 = 52706
(-209)^2 + 95^2 = 52706
95^2 + 209^2 = 52706
209^2 + (-95)^2 = 52706
(-209)^2 + (-95)^2 = 52706
(-95)^2 + 209^2 = 52706
209^2 + 95^2 = 52706
95^2 + (-209)^2 = 52706

Please log in to submit a solution to this problem

Log in