#abc360e. E - Random Swaps of Balls
E - Random Swaps of Balls
Score : points
问题陈述
有 个白球和一个黑球。这 个球排成一行,黑球最初位于最左边的位置。
高桥将执行以下操作恰好 次。
- 随机选择两个整数,分别在 到 (包括 和 )之间,记为 和 。如果 ,则交换从左边数第 个和第 个球。
经过 次操作后,黑球位于从左边数第 个位置。求 的期望值,对 取模。
模下的期望值是多少?可以证明,所求的期望值总是有理数。此外,在这个问题的约束条件下,可以证明如果这个值表示为最简分数 ,那么 。因此,存在一个唯一的整数 使得 $R \times Q \equiv P \pmod{998244353}, 0 \leq R < 998244353$。报告这个 。
以上为大语言模型 kimi 翻译,仅供参考。
Problem Statement
There are white balls and one black ball. These balls are arranged in a row, with the black ball initially at the leftmost position.
Takahashi will perform the following operation exactly times.
- Choose an integer uniformly at random between and , inclusive, twice. Let and the chosen integers. If , swap the -th and -th balls from the left.
After operations, let the black ball be at the -th position from the left. Find the expected value of , modulo .
What is expected value modulo ? It can be proved that the sought expected value will always be rational. Additionally, under the constraints of this problem, it can be proved that if this value is expressed as an irreducible fraction , then . Therefore, there exists a unique integer such that $R \times Q \equiv P \pmod{998244353}, 0 \leq R < 998244353$. Report this .
Constraints
Input
The input is given from Standard Input in the following format:
Output
Print the answer in one line.
Sample Input 1
2 1
Sample Output 1
499122178
After one operation, the probabilities that the black ball is at the 1st position and the 2nd position from the left are both . Thus, the expected value is .
Sample Input 2
3 2
Sample Output 2
554580198
Sample Input 3
4 4
Sample Output 3
592707587