#abc314f. F - A Certain Game
F - A Certain Game
Score : points
问题描述
设有 名玩家,编号分别为 player 、player 、...、player ,参加一场游戏锦标赛。在比赛开始前,每位玩家各自组成一个单人队伍,因此总共有 支队伍。
锦标赛共包含 场比赛。每场比赛中,会选取两支不同的队伍进行对决。一支队伍先手,另一支队伍后手。每场比赛将会有且仅有一支队伍获胜。具体来说,对于每场第 的比赛,其过程如下:
- 拥有玩家 的队伍先手,拥有玩家 的队伍后手。
- 设第一队和第二队的队员人数分别为 和 ,则第一队获胜的概率为 ,第二队获胜的概率为 。
- 然后,两支队伍合并为一支队伍。
每场比赛的结果相互独立。
对于这 名玩家中的每一位,请输出在整个锦标赛期间,该玩家所在队伍预期获胜的次数对 取模后的结果。
如何打印模 下的期望值
可以证明所求的期望值始终是理性的。同时,本问题的约束条件保证了如果所求期望值表示为不可约分数 ,则 不会被 整除。
现在存在一个唯一的整数 ,满足 ,且 。请报告这个 值。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
players, player , player , ..., player , participate in a game tournament. Just before the tournament starts, each player forms a one-person team, so there are teams in total.
The tournament has a total of matches. In each match, two different teams are chosen. One team goes first, and the other goes second. Each match will result in exactly one team winning. Specifically, for each , the -th match proceeds as follows.
- The team with player goes first, and the team with player goes second.
- Let and be the numbers of players in the first and second teams, respectively. The first team wins with probability , and the second team wins with probability .
- Then, the two teams are combined into a single team.
The result of each match is independent of those of the others.
For each of the players, print the expected number of times the team with that player wins throughout the tournament, modulo .
How to print an expected value modulo
It can be proved that the sought expected value is always rational. Also, the constraints of this problem guarantee that if the sought expected value 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
- Just before the -th match, player and player belong to different teams.
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
For each , print , the expected number, modulo , of times the team with player wins throughout the tournament, separated by spaces, in the following format:
Sample Input 1
5
1 2
4 3
5 3
1 4
Sample Output 1
698771048 698771048 964969543 964969543 133099248
We call a team formed by player , player , , player as team .
- The first match is played by team , with player , and team , with player . Team wins with probability , and team wins with probability . Then, the two teams are combined into a single team .
- The second match is played by team , with player , and team , with player . Team wins with probability , and team wins with probability . Then, the two teams are combined into a single team .
- The third match is played by team , with player , and team , with player . Team wins with probability , and team wins with probability . Then, the two teams are combined into a single team .
- The fourth match is played by team , with player , and team , with player . Team wins with probability , and team wins with probability . Then, the two teams are combined into a single team .
The expected numbers of times the teams with players win throughout the tournament, , are $\frac{9}{10}, \frac{9}{10}, \frac{53}{30}, \frac{53}{30}, \frac{14}{15}$, respectively.
Sample Input 2
15
9 2
8 10
13 6
12 11
7 10
4 10
14 2
5 4
1 15
15 2
6 9
8 11
6 3
2 8
Sample Output 2
43970290 310168785 806914186 501498951 950708909 272140427 335124893 168750835 310168785 168750835 280459129 280459129 272140427 476542843 43970290
update @ 2024/3/10 08:59:19