Based Zeros
Time limit2sMemory limit1024 MB
For each n, find the largest number of zero digits that n can have in any base from 2 to n, and list every base that reaches that count.
- Level
Medium7 of 10
- Topics
- Number theory, Math, Brute force
- Solved
- No attempts yet
Problem
Barbara has always known how to write integers in the decimal system (base ten), using the digits . Recently she learned that for any integer base , she can also write integers in base , using the symbols with values from to as digits.
Barbara's favorite digit is . Luckily, it looks the same in all bases.
Today Barbara is playing with a positive integer . She wonders in which bases the representation of contains the most zeros. Find all such bases.
Input
The first line contains the number of test cases (). Each test case is a single line containing one integer ().
Output
For each test case, print two integers and on the first line. Here is the maximum number of zeros that the representation of can have in any base, and is the number of bases that reach it.
On the second line, print the bases in increasing order ().
Hint
The representations with the maximum number of zeros for the sample cases are:
- (one zero)
- (two zeros)
- (one zero)
In , is a digit with value .