#abc333f. F - Bomb Game 2
F - Bomb Game 2
Score : points
问题描述
有 名人员站成一排,第 个人站在从前往数的第 个位置。
重复以下操作直到队伍中只剩一个人:
- 以 的概率移除队伍最前面的人,否则将其移动至队伍末尾。
对于每个人员 ,求在模 下,人员 成为最后剩下的人的概率。(每次选择移除或不移除都是随机且独立的。)
如何寻找模 下的概率
本问题中所求的概率可以证明总是有理数。此外,此问题的约束条件保证了如果所求概率表示为不可约分数 ,则 不会被 整除。
现在,存在一个唯一的整数 ,满足 (包含两端点),使得 。请报告这个 值。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
There are people standing in a line, with person standing at the -th position from the front.
Repeat the following operation until there is only one person left in the line:
- Remove the person at the front of the line with a probability of , otherwise move them to the end of the line.
For each person , find the probability that person is the last person remaining in the line, modulo . (All choices to remove or not are random and independent.)
How to find probabilities modulo
The probabilities sought in this problem can be proven to always be a rational number. Furthermore, the constraints of this problem guarantee that if the sought probability is expressed as an irreducible fraction , then is not divisible by .
Now, there is a unique integer between and , inclusive, such that . Report this .
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the answer for people , separated by spaces.
Sample Input 1
2
Sample Output 1
332748118 665496236
Person will be the last person remaining in the line with probability .
Person will be the last person remaining in the line with probability .
Sample Input 2
5
Sample Output 2
235530465 792768557 258531487 238597268 471060930
update @ 2024/3/10 01:20:26