Favourite Number
Time limit1sMemory limit512 MB
Given K, list every positive integer A such that both A and A+K have an odd number of divisors.
- Level
Medium5 of 10
- Topics
- Math, Number theory, Implementation, Brute force
- Solved
- No attempts yet
Problem
Volodymyr's favourite number is A, and it has an odd number of positive divisors. When you add K to this number, the resulting sum also has an odd number of positive divisors. Given K, find all possible values of A, Volodymyr's favourite number.
Input
The only line of input contains K, a positive integer not exceeding 10^9$.
Output
On the first line, print the number of possible values of A. On the second line, print all possible values of A in ascending order, separated by a single space.
Hint
Since zero has infinitely many divisors, it cannot be classified as a number with an odd number of divisors.