#P1044. [NOIP 2003 普及组] 栈
[NOIP 2003 普及组] 栈
Description

Ningning considers the following problem: given an operand sequence (the figure illustrates the case for to ), stack A has depth greater than .
Two operations are allowed:
- Move a number from the head of the operand sequence to the top of the stack (corresponding to the stack push operation).
- Move a number from the top of the stack to the end of the output sequence (corresponding to the stack pop operation).
Using these two operations, one operand sequence can produce a set of output sequences. The following figure shows the process of generating the sequence 2 3 1 from 1 2 3.

(The initial state is as shown above.)
For a given , your program should compute and output the total number of output sequences that can be obtained from the operand sequence through these operations.
Input Format
The input contains a single integer ().
Output Format
Output a single line containing the total number of possible output sequences.
3
5
Hint
Source: NOIP 2003 Junior, Problem 3.
Translated by ChatGPT 5
京公网安备 11011102002149号