Bet any fraction of your money each round to maximize the chance of ending with at least one million dollars.
Hard8Dynamic programmingProbabilityMathNo attempts yetTime limit5sMemory limit512 MBYou are invited to the TV show "Would you like to be a millionaire?". The rules are these.
You are given M, P and X. Play so that the chance of becoming a millionaire is as large as possible, and compute the probability of ending with $1000000 or more.
The first line contains the number of test cases N.
Each of the next N lines contains M, P and X, separated by single spaces.
Limits:
For each test case, print one line Case #x: y, where x is the test case number starting at 1 and y is the probability of becoming a millionaire.
Print y rounded to six digits after the decimal point, padded with zeros so that there are always exactly six digits. Round up when the seventh digit is 5. A probability of exactly 1 prints as 1.000000 and a probability of exactly 0 prints as 0.000000.
With M=1, P=0.5 and X=500000, the only way to reach $1000000 is to bet everything in the single round, so the probability is 0.5.
With M=3, P=0.75 and X=600000 you can play so that you still reach $1000000 after losing one round. Here is one such plan.