#P1028. [NOIP 2001 普及组] 数的计算

[NOIP 2001 普及组] 数的计算

Description

Given a positive integer nn, construct sequences in the following way.

  1. A sequence consisting of only the number nn is a valid sequence.
  2. By appending a positive integer to the end of a valid sequence, if this integer does not exceed half of the last term of the sequence, the new sequence is also valid.

Please find how many valid sequences there are in total. Two valid sequences a,ba, b are different if and only if their lengths are different, or there exists a positive integer iai \leq |a| such that aibia_i \neq b_i.

Input Format

The input consists of a single line with one integer nn.

Output Format

Output a single integer, the number of valid sequences.

6

6

Hint

Explanation for Sample 1

The sequences that meet the conditions are:

  • 66.
  • 6,16, 1.
  • 6,26, 2.
  • 6,36, 3.
  • 6,2,16, 2, 1.
  • 6,3,16, 3, 1.

Constraints

For all test points, it is guaranteed that 1n1031 \leq n \leq 10^3.

Notes

The testdata of this problem comes from the first problem of NOIP 2001 Junior. However, the original statement and the testdata do not match, so the statement has been modified here to match the testdata. The original statement is provided below for reference:

We want to find the number of numbers with the following properties (including the input positive integer nn).

First input a positive integer nn (n1000n \le 1000), and then process this integer as follows:

  1. Do nothing.
  2. Concatenate a positive integer to its left, but this positive integer cannot exceed the original number, or half of the last concatenated number.
  3. After adding a number, continue processing according to this rule until no more positive integers can be added.

Thanks to

/user/120868
edback on this problem. The issue with the original statement can be found in this post.

Translated by ChatGPT 5