問題一覧 > 通常問題

No.1348 Split Tile

レベル : / AI推定難易度 : 1600 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 59
作問者 : PCTprobability / テスター : KoD maguro blackyuki
お気に入りにしたユーザー ProblemId : 5750 / 自分の提出
問題文最終更新日: 2021-01-16 17:42:34
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
灘中入試コンテストday1 (順位表) の他の問題:

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$.
There are $N!$ possible ways the game can proceed. Find the sum of the final values of $X$ over all of them, modulo $998244353$. Here, $2$ ways the game can proceed are considered different if there exists a positive integer $i$ such that the number of the tile removed on turn $i$ differs between the $2$ games.

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もしくは右上の雲マークをクリックしてアカウントを作成してください。