Diet
Time limit2sMemory limit128 MB
Given G, find all natural numbers a such that a^2 minus some natural number's square equals G, printing them in increasing order or -1 if none exist.
- Level
Easy3 of 10
- Topics
- Math, Number theory, Brute force
- Solved
- No attempts yet
Problem
Sungwon is trying to diet. To see how his weight has changed from the weight he remembers, he steps onto a new scale. The scale reports a value G kg, defined as the square of his current weight minus the square of the weight he remembers.
Assume both weights are natural numbers. Given G, write a program that prints every possible current weight.
Input
The first line contains G. G is a natural number not greater than 100,000.
Output
Print all possible current weights in increasing order, one per line, starting from the first line. If there is no possible current weight, print -1.
Cases where the current weight is not a natural number must be excluded.