AtCoder Regular Contest 134
F
Flipping Coins
AtCoder
⌀ 3530
原题
← E→
翻译中…

Problem Statement

翻译中…

There are $N$ coins numbered $1, 2, \ldots, N$ arranged in a row. Initially, all coins face up.

翻译中…

Snuke chooses a permutation $p$ of $(1,\ldots,N)$ with equal probability, and do $N$ operations. The $i$-th operation does the following.

翻译中…
  • If the coin numbered $i$ faces down, do nothing.
  • If the coin numbered $i$ faces up, turn that coin over and then turn over the coin numbered $p_i$.
翻译中…

After the $N$ operations, Snuke will receive $W^k$ yen (Japanese currency) from his mother, where $k$ is the number of coins facing up.

翻译中…

Find the expected value of the amount Snuke will get, multiplied by $N!$ (it can be proved that this is an integer), modulo $998244353$.

翻译中…

Constraints

翻译中…
  • All values in input are integers.
  • $1 \leq N \leq 2 \times 10^5$
  • $1 \leq W < 998244353$
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

N W

翻译中…

Output

翻译中…

Print the expected value of the amount Snuke will get, multiplied by $N!$, modulo $998244353$.

翻译中…

样例

Input #1
4 2
Output #1
90
- When $p=(1,4,2,3)$, the operations go as follows. - In the $1$-st operation, the coin numbered $1$ faces down, and then the coin numbered $1$ faces up. - In the $2$-nd operation, the coin numbered $2$ faces down, and then the coin numbered $4$ faces down. - In the $3$-rd operation, the coin numbered $3$ faces down, and then the coin numbered $2$ faces up. - In the $4$-th operation, nothing is done. - In the end, two coins face up, so he receives $4$ yen.
Input #2
2 100
Output #2
10001
Input #3
200000 12345
Output #3
541410753
- Be sure to find the value modulo $998244353$.
题目信息
题号
arc134_f
时间限制
5 s
内存限制
1024 MB

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