Олимпиадный тренинг

Задача 33145. Full squares


Задача

Темы:
In order to search for patterns, it is sometimes useful to generate a long sequence according to certain rules. It is known, for example, that the sequence 0, 0+ 1, 0+ 1+ 3, 0+ 1+ 3+ 5,
. . . , 0 + 1 + 3 + . . . + (2n − 1), . . ., composed of the sums of the first few odd natural numbers, consists of the squares of integers: 0, 1, 4, 9, . . . , n2, . . ..
We generalize this sequence as follows: we will use the number k instead of zero instead of the initial value. We get the sequence: k, k + 1, k + 1 + 3, k + 1 + 3 + 5, . . . ,k+ 1+ 3+. . .+ (2n−1), . . ..  In contrast to the case k = 0, this sequence may contain more than just perfect squares. It is necessary to find the minimum integer non-negative number whose square occurs in this sequence.

It is required to write a program that, given an integer k, determines the square of which minimum non-negative integer occurs in the described sequence,
or finds out that there are no perfect squares in it at all.

Input data format
The single line contains the integer k — seed in sequence
(−1012 <= k <= 1012).
Note that a 64-bit data type must be used to read and store such a large number.

Output format
Print the minimum non-negative integer whose square occurs in the described
sequences. If there are no squares of integers in the sequence, print
"none".

Enter Output
0 0
-5 2
2 none