Hide

Problem G
Capture the Minions

Gru, a former super-villian, is known for his deadly army of minions. It is no doubt that this minion army played a major role in helping Gru become the most powerful villain. Knowing this, another super-villain named "El Macho" wants to capture the minions and force them into his own army. He possesses a powerful mutagen known as PX-41 which can turn the yellow minions into insane, savage, purple-fur-covered monsters. Gru, on the other hand, has an antidote that can revert mutated minions back to their natural yellow state. El Macho and Gru will never run out of these potions, so they could keep transforming minions back and forth, from purple to yellow, forever. Instead, they decide to settle their way with the help of a single, standard, six-faced die in a game of Capturing the Minions.

The number of minions in the armies of Gru and El Macho are denoted as $M_ G$ and $M_ E$, respectively, and at the start of the game you are given constant C (the capturing ability) and constant T (the transform capacity). The game is played in turns. At each turn, the single die is rolled; if the resulting value is less than or equal to C, then Gru wins the turn, but otherwise El Macho wins. The winner then transforms T number of minions to their side. That is, T minions are subtracted from the loser’s army and added to the winner’s army. The game continues until the number of minions of one of the villains is less than or equal to zero.

For example, suppose $M_ G$ = 7, $M_ E$ = 5, C = 2, and T = 4. The dice is rolled and the result value is 3. Then El Macho wins the turn, and therefore Gru loses 4 minions while El Macho gains 4 minions. The new number of their armies would be $M_ G$ = 3 and $M_ E$ = 9. Notice that if El Macho wins again on the next turn, the game ends. The value of C and T are constant throughout the game; only $M_ G$ and $M_ E$ vary. Gru can’t afford to lose his minions, so he has asked for your help to compute his chance of winning the game, given a starting number of minions on both sides.

Input

The input contains several test cases. Each test case is given in one single line, containing four integers $M_ G$, $M_ E$, C, and T, separated by spaces ($1 \leq M_ G, M_ E \leq 10, 1 \leq C \leq 5$, and $1 \leq T \leq 10$). The end of the input is indicated by one line containing only four zeros, separated by spaces.

Output

For each test case in the input, your program must print out one line that contains the probability that Gru wins the battle. This probability is equivalent to a percentage, represented in the output as a real number with exactly one decimal figure.

Sample Input 1 Sample Output 1
4 3 5 2
2 1 3 2
2 4 5 2
5 7 3 8
0 0 0 0
96.2
50.0
80.6
50.0

Please log in to submit a solution to this problem

Log in