#P1028. [NOIP 2001 普及组] 数的计算
[NOIP 2001 普及组] 数的计算
Description
Given a positive integer , construct sequences in the following way.
- A sequence consisting of only the number is a valid sequence.
- 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 are different if and only if their lengths are different, or there exists a positive integer such that .
Input Format
The input consists of a single line with one integer .
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:
- .
- .
- .
- .
- .
- .
Constraints
For all test points, it is guaranteed that .
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 ).
First input a positive integer (), and then process this integer as follows:
- Do nothing.
- Concatenate a positive integer to its left, but this positive integer cannot exceed the original number, or half of the last concatenated number.
- After adding a number, continue processing according to this rule until no more positive integers can be added.
Thanks to
Translated by ChatGPT 5
京公网安备 11011102002149号