Problem T
Loot Chest
Your favorite online game has a prize system. After each
match you win, there is a
-
every time you lose a match,
increases by , -
every time you win a match but fail to receive a prize,
increases by , and -
every time you win a match and receive a prize,
is set to .
Whenever
The developers just revealed one of the prizes this season
is a silverback gorilla suit with star-shaped sunglasses. You
want it! Each prize has a
You start with
For example, in the first sample case you win every match
you play and are guaranteed to receive a prize every
Input
The input consists of a single line containing four integers
Output
Display the expected number of matches you will play before
you obtain the gorilla suit. Your answer should have an
absolute or relative error of at most
Sample Input 1 | Sample Output 1 |
---|---|
1 100 50 0 |
4 |
Sample Input 2 | Sample Output 2 |
---|---|
50 50 100 25 |
2.8333333333333333333 |
Sample Input 3 | Sample Output 3 |
---|---|
1 100 10 0 |
20 |
Sample Input 4 | Sample Output 4 |
---|---|
2 3 10 80 |
197.00570671995630567 |