Based Zeros

시간 제한2초메모리 제한1024 MB

요약
각 n에 대해 n을 b진법으로 나타냈을 때 0이 가장 많이 나오는 진법 b를 모두 구한다.
난이도

어려움10점 중 8점

유형
수학, 정수론, 완전 탐색, 구현
정답자
아직 제출이 없습니다

문제

Barbara has always known how to represent integers in the decimal numeral system (base ten), using digits 0,1,2,…,90, 1, 2, \ldots, 9. Recently she has learned that for any integer base b≥2b \ge 2, she can also represent integers in base bb, using symbols with values from 00 to b−1b-1, inclusive, as digits.

Barbara's favorite digit is 00. Luckily, it looks the same in all bases.

Today Barbara is playing with a positive integer nn. Now she wonders: in what bases does the representation of nn contain the biggest number of zeros? Help her to find all such bases.

입력

Each test contains multiple test cases. The first line contains the number of test cases tt (1≤t≤10001 \le t \le 1000). The description of the test cases follows.

The only line of each test case contains a single integer nn (2≤n≤10182 \le n \le 10^{18}).

출력

For each test case, in the first line, print two integers kk and mm, denoting the maximum number of zeros the representation of nn can have in any integer base, and the number of such bases, respectively.

In the second line, print mm integers b_1,b_2,…,b_mb\_1, b\_2, \ldots, b\_m, denoting all such bases in increasing order (2≤b_1<b_2<⋯<b_m≤n2 \le b\_1 < b\_2 < \cdots < b\_m \le n).

힌트

Here are the representations with the maximum number of zeros for the example test cases:

  • 11=1011_2=102_3=10_1111 = \mathtt{1011}\_2 = \mathtt{102}\_3 = \mathtt{10}\_{11} (one zero);
  • 1007=1101022_3=1007_101007 = \mathtt{1101022}\_3 = \mathtt{1007}\_{10} (two zeros);
  • 239=11101111_2=1035_6=10E_15=10_239239 = \mathtt{11101111}\_2 = \mathtt{1035}\_6 = \mathtt{10E}\_{15} = \mathtt{10}\_{239} (one zero).

In the 239=10E_15239 = \mathtt{10E}\_{15} representation, E\mathtt{E} stands for a digit with the value of 1414.

예제1

  1. 예제 1

    입력
    3
    11
    1007
    239
    
    예상 출력
    1 3
    2 3 11
    2 2
    3 10
    1 4
    2 6 15 239