#P1066. [NOIP 2006 提高组] 2^k 进制数

[NOIP 2006 提高组] 2^k 进制数

Description

Let rr be a base 2k2^k number that satisfies the following conditions.

  • rr has at least 22 digits in base 2k2^k.
  • As a base 2k2^k number, except for the last digit, each digit of rr is strictly less than the digit immediately to its right.
  • After converting rr to its binary representation qq, the total number of bits of qq does not exceed ww.

Here, the positive integers k,wk, w are given in advance.

Question: How many different rr satisfy the conditions above?

We further explain from another angle: Let SS be a length-ww 0101 string (i.e., SS consists of ww characters, each being 00 or 11), and SS corresponds to the qq mentioned in condition 33. Partition SS from the right into blocks of length kk, each block corresponding to one digit in base 2k2^k. If SS can be partitioned into at least 22 blocks, then the binary number represented by SS can be converted into the base 2k2^k number rr described above.

Example: Let k=3,w=7k=3, w=7. Then rr is an octal number (23=82^3=8). Since w=7w=7, a length-77 0101 string, when split into blocks of 33 bits, can be divided into 33 blocks (namely 1,3,31, 3, 3; the leftmost block has only one binary bit). The octal numbers that satisfy the conditions are:

22-digit numbers:
High digit is 11: 66 numbers (namely 12,13,14,15,16,1712, 13, 14, 15, 16, 17),
High digit is 22: 55 numbers,
...,
High digit is 66: 11 number (namely 6767).
In total, 6+5++1=216+5+…+1=21 numbers.

33-digit numbers:
The high digit can only be 11,
Second digit is 22: 55 numbers (namely 123,124,125,126,127123, 124, 125, 126, 127),
Second digit is 33: 44 numbers,
...,
Second digit is 66: 11 number (namely 167167).
In total, 5+4++1=155+4+…+1=15 numbers.

Therefore, the total number of rr that satisfy the requirements is 3636.

Input Format

One line containing two positive integers k,wk, w separated by a space.

Output Format

Output one line with a single positive integer: the required result.
That is, the number of different rr 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 200200 digits.)

3 7
36

Hint

Constraints
1k91\le k \le 9
1w3×1041\le w \le 3\times 10^4

NOIP 2006 Senior Problem 4.

Translated by ChatGPT 5