atcoder#MSOLUTIONS2019C. Best-of-(2n-1)
Best-of-(2n-1)
Score : points
Problem Statement
Takahashi and Aoki will play a game. They will repeatedly play it until one of them have wins in total.
When they play the game once, Takahashi wins with probability %, Aoki wins with probability %, and the game ends in a draw (that is, nobody wins) with probability %. Find the expected number of games that will be played, and print it as follows.
We can represent the expected value as with coprime integers and . Print the integer between and (inclusive) such that . (Such an integer always uniquely exists under the constraints of this problem.)
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the expected number of games that will be played, in the manner specified in the statement.
1 25 25 50
2
Since , they will repeat the game until one of them wins. The expected number of games played is .
4 50 50 0
312500008
may be .
1 100 0 0
1
may also be .
100000 31 41 28
104136146