#P1066. [NOIP 2006 提高组] 2^k 进制数
[NOIP 2006 提高组] 2^k 进制数
Description
Let be a base number that satisfies the following conditions.
- has at least digits in base .
- As a base number, except for the last digit, each digit of is strictly less than the digit immediately to its right.
- After converting to its binary representation , the total number of bits of does not exceed .
Here, the positive integers are given in advance.
Question: How many different satisfy the conditions above?
We further explain from another angle: Let be a length- string (i.e., consists of characters, each being or ), and corresponds to the mentioned in condition . Partition from the right into blocks of length , each block corresponding to one digit in base . If can be partitioned into at least blocks, then the binary number represented by can be converted into the base number described above.
Example: Let . Then is an octal number (). Since , a length- string, when split into blocks of bits, can be divided into blocks (namely ; the leftmost block has only one binary bit). The octal numbers that satisfy the conditions are:
-digit numbers:
High digit is : numbers (namely ),
High digit is : numbers,
...,
High digit is : number (namely ).
In total, numbers.
-digit numbers:
The high digit can only be ,
Second digit is : numbers (namely ),
Second digit is : numbers,
...,
Second digit is : number (namely ).
In total, numbers.
Therefore, the total number of that satisfy the requirements is .
Input Format
One line containing two positive integers separated by a space.
Output Format
Output one line with a single positive integer: the required result.
That is, the number of different that satisfy the conditions (in decimal). There must be no leading zeros, and no characters other than digits may be inserted between digits (such as spaces, line breaks, commas, etc.).
(Hint: The resulting positive integer may be large, but it will not exceed digits.)
3 7
36
Hint
Constraints
NOIP 2006 Senior Problem 4.
Translated by ChatGPT 5
京公网安备 11011102002149号