#abc293f. F - Zero or One

F - Zero or One

Score : 500500 points

问题描述

给定一个不小于 22 的整数 NN,找出满足以下条件的不小于 22 的整数 bb 的个数:

  • NNbb 进制表示时,每个数字均为 0011

TT 个独立的测试用例求解答案。

可以证明,在本题约束条件下,满足条件的不小于 22 的整数 bb 有有限个。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

Given an integer NN not less than 22, find the number of integers bb not less than 22 such that:

  • when NN is written in base bb, every digit is 00 or 11.

Find the answer for TT independent test cases.

It can be proved that there is a finite number of desired integers bb not less than 22 under the constraints of this problem.

Constraints

  • 1T10001 \leq T \leq 1000
  • 2N10182 \leq N \leq 10^{18}
  • All values in the input are integers.

Input

The input is given from Standard Input in the following format, where testi\mathrm{test}_i denotes the ii-th test case:

TT

test1\mathrm{test}_1

test2\mathrm{test}_2

\vdots

testT\mathrm{test}_T

Each test case is given in the following format:

NN

Output

Print TT lines. For i=1,2,,Ti = 1, 2, \ldots, T, the ii-th line should contain the answer to the ii-th test case.

Sample Input 1

3
12
2
36

Sample Output 1

4
1
5

For the first test case, four bb's satisfy the condition in the problem statement: b=2,3,11,12b = 2, 3, 11, 12. Indeed, when N=12N=12 is written in base 2,3,112, 3, 11, and 1212, it becomes 1100,110,111100, 110, 11 and 1010, respectively.

update @ 2024/3/10 12:12:53