No.1348 Split Tile
タグ : / 解いたユーザー数 59
作問者 :
PCTprobability
/ テスター :
KoD
maguro
Problem Statement
You are given a positive integer $N$. Tiles numbered from $1$ to $N$ are arranged in $1$ horizontal row in the order of numbers $1,2,...,N$. Tile $A$ and tile $B$ are said to be connected if $|A-B|=1$ and both tile $A$ and tile $B$ remain. We play a game consisting of $N$ turns as described below. Initially, the variable $X$ is initialized to $0$.
- Choose $1$ of the remaining tiles and remove it.
- Add the number of connected components of the tiles currently remaining to $X$.
Input
$N$
- All inputs are positive integers.
- $1 \le N \le 10^6$
Output
There are $N!$ possible ways the game can proceed. Find the sum of the final values of $X$ over all of them, modulo $998244353$.
Sample
Sample 1
Input
3
Output
14
For example, if the tiles are removed in the order $2,1,3$, then $X$ becomes $2+1+0=3$.
Sample 2
Input
2021
Output
421978734
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。