#P4204. [NOI2006] 神奇口袋
[NOI2006] 神奇口袋
Description
Pòlya obtained a marvelous pocket inscribed with symbols beyond human understanding. Fascinated, he pondered and discovered a magical model (later called the "Pòlya model"). To vividly teach this model, he had his students play a virtual game: at the beginning, put balls of color , balls of color , …, and balls of color into the bag, where ().
After the game starts, repeat the following operation strictly each time:
Randomly draw one ball from the bag (all balls in the bag are equally likely to be drawn), Pòlya observes the color of this ball and puts it back, then adds more balls of the same color into the pocket.
Let be the color of the ball drawn on the -th draw (). A single game run produces a color sequence . Pòlya tells all students the initial counts of balls of the colors, namely . Then he asks the students: what is the probability that a single run produces a color sequence satisfying
$$c_{x_1}=y_1, c_{x_2}=y_2, \ldots, c_{x_n}=y_n \, ?$$Here , and . In other words, given $(t, n, d, a_1, a_2, \ldots, a_t, x_1, y_1, x_2, y_2, \ldots, x_n, y_n)$, you need to answer the probability of the following event: “for all (), the color of the -th draw is .”
Input Format
- The first line contains three positive integers .
- The second line contains positive integers , representing the number of balls of each of the colors at the beginning of the game.
- Each of the next lines contains two positive integers , indicating that on the -th draw the color is .
Output Format
Output the probability as a fraction (this probability is clearly rational). The output contains one line in the format: numerator/denominator. It must be in lowest terms (the numerator and denominator are coprime). In particular, if the probability is , output 0/1; if the probability is , output 1/1.
2 3 1
1 1
1 1
2 2
3 1
1/12
3 1 2
1 1 1
5 1
1/3
Hint
[Sample Explanation #1]
Initially, the counts of the two colors are , so the probability of drawing a ball of color is . Before the second draw, the counts become , so the probability of drawing a ball of color is . Before the third draw, the counts become , so the probability of drawing a ball of color is . Therefore, the total probability of the three draws is .
Constraints
For of the testdata, , , , .
Translated by ChatGPT 5
京公网安备 11011102002149号