CodeTON Round 9 (Div. 1 + Div. 2, Rated, Prizes!)
E
Shohag Loves Inversions
Codeforces
2200
原题
← DF1 →
翻译中…

Shohag has an array $a$ of integers. Initially $a = [0, 1]$. He can repeatedly perform the following operation any number of times:

翻译中…
  • Let $k$ be the number of inversions$^{\text{∗}}$ in the current array $a$.
  • Insert $k$ at any position in $a$, including the beginning or the end.
翻译中…

For example, if $a = [4, 6, 2, 4]$, then the number of inversions is $k = 3$. So Shohag can obtain the following arrays after the operation: $[\textbf{3}, 4, 6, 2, 4]$, $[4, \textbf{3}, 6, 2, 4]$, $[4, 6, \textbf{3}, 2, 4]$, $[4, 6, 2, \textbf{3}, 4]$, and $[4, 6, 2, 4, \textbf{3}]$.

翻译中…

Given an integer $n$, help Shohag count, modulo $998\,244\,353$, the number of distinct arrays of length $n$ that can be obtained after performing the operations.

翻译中…

$^{\text{∗}}$The number of inversions in an array $a$ is the number of pairs of indices ($i$, $j$) such that $i \lt j$ and $a_i \gt a_j$.

翻译中…

Input

翻译中…

The first line contains a single integer $t$ ($1 \le t \le 10^4$) — the number of test cases.

翻译中…

The first and only line of each test case contains an integer $n$ ($2 \le n \le 10^6$).

翻译中…

It is guaranteed that the sum of $n$ over all test cases does not exceed $10^6$.

翻译中…

Output

翻译中…

For each test case, output an integer — the number of possible arrays modulo $998\,244\,353$.

翻译中…

Note

翻译中…

In the first test case, the following $5$ arrays can be obtained (the inserted inversion count is shown in bold):

翻译中…
  • $[0, 1] \rightarrow [0, \textbf{0}, 1] \rightarrow [0, 0, 1, \textbf{0}]$,
  • $[0, 1] \rightarrow [0, \textbf{0}, 1] \rightarrow [0, 0, \textbf{0}, 1]$,
  • $[0, 1] \rightarrow [0, 1, \textbf{0}] \rightarrow [0, 1, 0, \textbf{1}]$,
  • $[0, 1] \rightarrow [0, 1, \textbf{0}] \rightarrow [0, 1, \textbf{1}, 0]$,
  • $[0, 1] \rightarrow [0, 1, \textbf{0}] \rightarrow [\textbf{1}, 0, 1, 0]$.
翻译中…

样例

Input #1
4
4
2
7
69
Output #1
5
1
682
325188814
InputCopy OutputCopy
题目信息
题号
2039E
时间限制
2 s
内存限制
256 MB
标签
组合数学
动态规划
模拟
数学

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。