Inverse Divisor Sums
Time limit3sMemory limit256 MB
Print every integer M whose divisor sum equals the given N in increasing order, or none when no such number exists.
- Level
Medium7 of 10
- Topics
- Backtracking, Number theory, Math
- Solved
- No attempts yet
Problem
Your friend Odd Even is obsessed with number theory. Every time he learns a new operation on numbers he spends hours applying it. Last year he learned Euler's totient function , which counts the positive integers up to that are relatively prime to , and then computed by hand for every integer from 1 to one million.
Recently he learned that the sum of all divisors of a number is given by the following formula.
Here is the factorization of into prime factors, each is different, and is the largest exponent such that divides .
Odd Even wants to run the function backwards. Given a positive integer he wants every positive integer whose sum of divisors is , written out in increasing order. Doing that by hand would take far too long, so you decided to write a program for him instead.
Given a positive integer , print every integer whose sum of divisors is in increasing order, or report that no such number exists.
Input
The first line contains the number of test cases . Each of the next lines contains one integer .
Output
For each test case, print every number whose sum of divisors is on one line in increasing order, with a single space between consecutive numbers. If no such number exists, print none! without the quotes.
The output can get very long, so collect it and write it out at once instead of printing line by line.