Under construction

Still being built. Things may change

Loot Chest

Interview

Time limit1sMemory limit1024 MB

Summary
Given that the prize chance grows on losses and non-prize wins and resets after any prize, compute the expected matches until a gorilla-suit prize.
Level

Medium6 of 10

Topics
Dynamic programming, Probability, Math
Solved
No attempts yet

Problem

Your favorite online game has a prize system. After each match you win, you receive a prize with probability P%P\%. The value of PP changes over time as follows:

  • Every time you lose a match, PP increases by ΔL\Delta_L.
  • Every time you win a match but do not receive a prize, PP increases by ΔW\Delta_W.
  • Every time you win a match and receive a prize, PP is set to 00.

Whenever PP increases, it is capped at 100100. That is, if PP is increased by Δ\Delta, then PP becomes min⁡(P+Δ,100)\min(P+\Delta, 100).

The developers have just revealed that one of the prizes this season is a silverback gorilla suit with star-shaped sunglasses. You want it! Each prize is this gorilla suit with probability G%G\%.

You start with P=0%P = 0\%. Each match you play has a L%L\% chance of being a loss. Given ΔL,ΔW,G,\Delta_L, \Delta_W, G, and LL, compute the expected number of matches you will play until you obtain the silverback gorilla suit.

For example, in the first sample case you win every match and are guaranteed to receive a prize every 2 matches. Each prize is the gorilla suit with probability 50%50\%. So you expect to obtain the gorilla suit after receiving 2 prizes. Thus, in expectation, it takes 4 matches to obtain the gorilla suit.

Input

The input consists of a single line containing four integers ΔL\Delta_L (1≤ΔL≤1001 \leq \Delta_L \leq 100), ΔW\Delta_W (1≤ΔW≤1001 \leq \Delta_W \leq 100), GG (1≤G≤1001 \leq G \leq 100), and LL (0≤L≤990 \leq L \leq 99), which are described above.

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 10−610^{-6}.

Examples4

  1. Example 1

    Input
    1 100 50 0
    
    Expected output
    4
    
  2. Example 2

    Input
    50 50 100 25
    
    Expected output
    2.8333333333333333333
    
  3. Example 3

    Input
    1 100 10 0
    
    Expected output
    20
    
  4. Example 4

    Input
    2 3 10 80
    
    Expected output
    197.00570671995630567