#P11440. Lucky Boxes

    ID: 13520 Type: Default 1000ms 256MiB

Lucky Boxes

Lucky Boxes

Little Ming has n lucky boxes. In each round, he can choose one of the following three strategies:

  1. Re‐run: Choose exactly k boxes and re‐operate them. Each box will yield a candy with probability \(p\%\) and mustard with probability \((100-p)\%\).
  2. Spell: Use magic by choosing exactly t boxes. For these boxes the candy probabilities are adjusted to
    \(p\%, \ \min(p+1,100)\%, \ \min(p+2,100)\%, \ldots, \ \min(p+t-1,100)\%\) respectively.
  3. Do nothing: Skip this round.

Little Ming is very smart and in every round he will choose the optimal strategy (either re‐running exactly k boxes, using a spell on exactly t boxes, or doing nothing) so that after m rounds his expected number of candies is maximized. Note that he cannot take out any box's content until after all rounds are finished; if a box is operated more than once, only the outcome from the final operation counts.

The outcome of each box is determined solely by the last operation applied to it. If a box is never operated, it yields nothing. In a re‐run operation the box’s candy probability is \(p\%\). In a spell operation the probabilities for the chosen t boxes are, in some order, \(p\%\) and several values larger than \(p\)% (namely, \(\min(p+1,100)\%\), \(\min(p+2,100)\%\), ..., \(\min(p+t-1,100)\%\)).

Assuming Little Ming uses the rounds optimally, compute his maximum expected number of candies after m rounds. The input contains five integers: n m k t p in one line. The answer should be printed as a real number with 6 decimal places.

Note on the Spell Operation: In a spell round, exactly t boxes are chosen. Their candy probabilities are adjusted such that one box gets \(p\%\), one box gets \(\min(p+1,100)\%\), one gets \(\min(p+2,100)\%\), and so on. When combining rounds, Little Ming may choose different boxes in different rounds; however, each box’s final candy chance is that from its last operation. He will assign each box at most one operation outcome.

inputFormat

The input consists of a single line containing five space‐separated integers:

  • n: the total number of boxes.
  • m: the total number of rounds.
  • k: the number of boxes operated in a re‐run round.
  • t: the number of boxes operated in a spell round.
  • p: the base candy probability (in percent) for re‐run rounds and the spell round's first box.

It is guaranteed that all numbers are positive integers.

outputFormat

Output a single line containing the maximum expected number of candies after m rounds. Print the answer as a floating‐point number with 6 decimal places.

sample

10 2 3 2 50
3.000000