No.3777 Train Seats
Problem Statement
$N$ chairs are lined up in a horizontal row. From now on, $N$ people will arrive in order, $1$ person at a time.
If there are $1$ or more chairs satisfying all of the following conditions, the newly arrived person chooses $1$ of them and sits on it.
- No one is sitting on the chair.
- There is no chair to its right, or no one is sitting on the chair to its right.
- There is no chair to its left, or no one is sitting on the chair to its left.
If no chair satisfies the conditions, the person chooses $1$ chair on which no one is sitting yet and sits on it.
Find the total number of possible orders in which the chairs are sat on, modulo $998244353$.
Input
$N$
The input satisfies the following constraints.
- All input values are integers.
- $1 \le N \le 1000$
Output
Find the total number of possible orders in which the chairs are sat on, modulo $998244353$.
Print a newline at the end.
Sample
Sample 1
Input
3
Output
4
Let chair $i$ denote the $i$-th chair from the left, and let chair $S_i$ be the chair on which the $i$-th person sits. Then the possible sequences $S$ are as follows.
- $(1, 3, 2)$
- $(2, 1, 3)$
- $(2, 3, 1)$
- $(3, 1, 2)$
Sample 2
Input
1
Output
1
Sample 3
Input
7
Output
1008
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。