#P5405. [CTS2019] 氪金手游
[CTS2019] 氪金手游
Description
Student Xiao Liu is a boy who likes pay-to-win mobile games.
He recently got addicted to a new game whose content is to keep drawing cards. It is known that:
- There are types of cards in the pool. The -th type of card has a weight . Xiao Liu does not know the exact value of , but by talking with other players he learned that follows a distribution.
- Specifically, for each , Xiao Liu knows three parameters . The value of is with probability . It is guaranteed that .
Xiao Liu starts playing the game. Each time, he pays 1 yuan to draw one card. The probability of drawing card is:
Xiao Liu will keep drawing cards until he has collected all types of cards.
After the drawing ends, the server records the time when Xiao Liu gets each card for the first time. The game company sets up an easter egg: the company prepares ordered pairs . If for every , the condition holds, then the company will consider Xiao Liu extremely lucky and will give him a cabinet of figurines as the lucky grand prize.
To reduce the chance of winning, these satisfy the following property: for any , there always exists some such that or .
Please compute the probability that Xiao Liu can get the lucky grand prize. It is guaranteed that the result is a rational number. Output the result modulo .
Input Format
The first line contains an integer , the number of card types.
The next lines each contain three integers , and the probabilities in the statement are given by $p_{i,j} = \frac{a_{i,j}}{a_{i,1} + a_{i,2} + a_{i,3}}$.
The next lines each contain two integers , describing an ordered pair (see the statement for its meaning).
Output Format
Output one integer in one line, the required probability modulo .
2
0 0 1
1 1 0
1 2
524078286
Hint
Explanation of Sample 1
is or with probability :
- If , then the probability that is .
- Otherwise, if , then the probability that is .
Combining all cases, the answer is $\frac 12\left(\frac 34 + \frac 35\right) = \frac{27}{40}$. You can verify that its value modulo is indeed the given output.
Testdata Constraints
For all testdata, it is guaranteed that and .
- points: .
- points: , and every constraint satisfies .
- points: , and every constraint satisfies .
- points: .
- points: no special constraints.
Translated by ChatGPT 5
京公网安备 11011102002149号