#P6673. [清华集训 2016] 石家庄的工人阶级队伍比较坚强
[清华集训 2016] 石家庄的工人阶级队伍比较坚强
Description
There are people playing rock-paper-scissors. There are a total of rounds, and in each round there are games of rock-paper-scissors.
Within the games of the same round, each person’s decisions must be fixed in advance. That is, they cannot use a randomized strategy, and they cannot decide the next game based on the results of previous games. Therefore, there are clearly possible strategies.
These people will all use pairwise different strategies. For convenience, for person (), convert to base to get an -digit number, where means scissors, means rock, and means paper. This gives the strategy used by person .
Since the indices are fixed, in the games of each round, everyone will always use the same set of decisions across different rounds.
Person initially has a score .
In round , he will play games of rock-paper-scissors against another person .
Let be the number of wins of against in these games. Let be the number of losses of against .
After round ends, person ’s score is:
where and . Draws are not counted; is a given scoring array.
Note that even if is the same as (transitioning from oneself to oneself), it will still be multiplied by a coefficient (because playing against oneself results in all draws).
Obviously, as the number of rounds increases, the scores will grow larger. This scoring system, like computers in daily use, can overflow. When a score to be stored is greater than or equal to , it becomes .
Mr. B wants to know everyone’s scores after rounds, i.e., .
Mr. G: “Hey, I found that this number has a special property! There do not exist two positive integers such that the sum of their reciprocals equals !”
Mr. B: “Mr. G is amazing! But how do we solve this problem?”
Input Format
The first line contains three integers .
The second line contains integers, representing . It is guaranteed that .
The following part is an array : the 1st line has numbers, the 2nd line has numbers, ..., and the -th line has number.
The -th number in the -th line is (). It is guaranteed that .
There do not exist two positive integers such that the sum of their reciprocals equals . That is, there do not exist positive integers such that .
Output Format
Output lines, each containing one integer, representing each person’s final score.
The -th line represents the -th person’s score .
1 1 10009
10 100 1000
2 3
4
4320
3240
2430
2 3 103
7 8 9 10 11 12 13 14 15
1 2 3
4 5
6
96
8
73
38
53
15
27
42
4
Hint
For all testdata, , , .
Translated by ChatGPT 5
京公网安备 11011102002149号