淘汰赛AI (CI翻译)
Problem Statement
题目描述
AI (CI翻译)There are $N$ cards arranged face down in a row, each with one of the integers $1,2,\dots,N$ written on its face.
The order of these cards is determined uniformly at random from the $N!$ possible orders.
You know that there is exactly one card with each of the integers $1,2,\dots,N$ written on its face and that the cards were arranged uniformly at random, but you have no other information about the integers written on the faces of the cards.
You play the following game.
- Initially, let the variable
$x=1$. - As long as
$x \le N$, repeat the following operation. One operation consists of the following three steps. - Specify one card and turn it face up.
- If the integer written on the card is
$x$, eat that card and add$1$to$x$. - Otherwise, turn that card face down. You can permanently remember the integer written on that card.
- If the integer written on the card is
You always act so that the expected value of the total number of operations until all cards have been eaten is minimized.
In this case, what is the probability that the total number of operations is $K$? Find it modulo $998244353$.
Definition of probability modulo $998244353$ It can be proved that the sought probability is always a rational number. Also, under the constraints of this problem, it can be proved that when the rational number to be found is expressed as an irreducible fraction $\frac{P}{Q}$, we have $Q {{}\not\equiv{}} 0 \pmod{998244353}$. Therefore, there is a unique integer $R$ satisfying $R \times Q \equiv P \pmod{998244353}, 0 \leq R \lt 998244353$. Output this $R$.
有 $N$ 张卡片正面朝下排成一列,每张卡片的正面写有 $1,2,\dots,N$ 中的一个整数。
这些卡片的排列顺序从 $N!$ 种可能的顺序中等概率随机确定。
你知道每个整数 $1,2,\dots,N$ 恰好分别写在一张卡片上,并且卡片是等概率随机排列的,但除此之外,你不知道卡片正面写的整数的任何信息。
你进行如下游戏。
- 初始时,令变量
$x=1$。 - 当
$x \le N$时,重复进行以下操作。一次操作由以下三个步骤组成。 - 指定一张卡片并将其翻开。
- 如果卡片上写的整数是
$x$,则吃掉这张卡片,并令$x$增加$1$。 - 否则,将这张卡片重新扣下。你可以永久记住这张卡片上写的整数。
- 如果卡片上写的整数是
你始终采取使吃掉所有卡片所需的操作总数的期望值最小的行动。
在这种情况下,操作总数为 $K$ 的概率是多少?请将答案对 $998244353$ 取模后输出。
概率对 $998244353$ 取模的定义
可以证明,所求概率总是有理数。此外,在本题约束条件下,可以证明:将待求有理数表示为既约分数 $\frac{P}{Q}$ 时,有 $Q {{}\not\equiv{}} 0 \pmod{998244353}$。因此,存在唯一的整数 $R$ 满足 $R \times Q \equiv P \pmod{998244353}$ 且 $0 \leq R \lt 998244353$。输出这个 $R$。AI (CI翻译)
Constraints
约束条件
AI (CI翻译)- All input values are integers.
$1 \le N \le 5 \times 10^5$$N \le K \le 10^9$
- 所有输入值均为整数。
$1 \le N \le 5 \times 10^5$$N \le K \le 10^9$
Input
输入格式
AI (CI翻译)The input is given from Standard Input in the following format:
输入从标准输入按以下格式给出:AI (CI翻译)
N K
N KAI (CI翻译)
Output
输出格式
AI (CI翻译)Output the answer.
输出答案。AI (CI翻译)
样例
3 4
499122177
3 6
0
500000 777777
251612105
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。