#abc226f. F - Score of Permutations
F - Score of Permutations
Score : points
问题描述
对于一个由 构成的排列 ,我们定义其得分 如下:
- 有 名编号为 的人,此外还有 Snuke。最初,编号为 的人持有第 号球。 每当 Snuke 大喊时,所有满足 的编号为 的人会同时将他们的球交给编号为 的人。 如果在至少大喊一次之后,每个编号为 的人都持有第 号球,则 Snuke 停止大喊。 得分是指 Snuke 在停止大喊前所大喊的次数。这里保证得分将是一个有限值。
存在 种由 构成的排列 。求这些排列中,每种排列的得分的 次方之和,结果对 取模。
- 形式上,令 表示由 构成的排列集合。计算以下表达式:$\displaystyle \left(\sum_{P \in S_N} S(P)^K \right) \bmod {998244353}$.
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
For a permutation of , let us define the score of as follows.
- There are people, numbered . Additionally, Snuke is there. Initially, Person has Ball .
Each time Snuke screams, every Person such that gives their ball to Person simultaneously.
If, after screaming at least once, every Person has Ball , Snuke stops screaming.
The score is the number of times Snuke screams until he stops. Here, it is guaranteed that the score will be a finite value.
There are permutations of . Find the sum, modulo , of the scores of those permutations, each raised to the -th power.
- Formally, let be the set of the permutations of . Compute the following: $\displaystyle \left(\sum_{P \in S_N} S(P)^K \right) \bmod {998244353}$.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print $\displaystyle \left(\sum_{P \in S_N} S(P)^K \right) \bmod {998244353}$.
Sample Input 1
2 2
Sample Output 1
5
When , there are two possible permutations : .
The score of the permutation is found as follows.
- Initially, Person has Ball , and Person has Ball .
After Snuke's first scream, Person has Ball , and Person has Ball .
Here, every Person has Ball , so he stops screaming.
Thus, the score is .
The score of the permutation is found as follows.
- Initially, Person has Ball , and Person has Ball .
After Snuke's first scream, Person has Ball , and Person has Ball .
After Snuke's second scream, Person has Ball , and Person has Ball .
Here, every Person has Ball , so he stops screaming.
Thus, the score is .
Therefore, the answer in this case is .
Sample Input 2
3 3
Sample Output 2
79
All permutations and their scores are listed below.
- : The score is .
- : The score is .
- : The score is .
- : The score is .
- : The score is .
- : The score is .
Thus, we should print .
Sample Input 3
50 10000
Sample Output 3
77436607
update @ 2024/3/10 09:56:07