atcoder#ABC293F. [ABC293F] Zero or One
[ABC293F] Zero or One
Score : points
Problem Statement
Given an integer not less than , find the number of integers not less than such that:
- when is written in base , every digit is or .
Find the answer for independent test cases.
It can be proved that there is a finite number of desired integers not less than under the constraints of this problem.
Constraints
- All values in the input are integers.
Input
The input is given from Standard Input in the following format, where denotes the -th test case:
Each test case is given in the following format:
Output
Print lines. For , the -th line should contain the answer to the -th test case.
3
12
2
36
4
1
5
For the first test case, four 's satisfy the condition in the problem statement: . Indeed, when is written in base , and , it becomes and , respectively.