Bet any fraction of your money over M rounds with win probability P; maximize the chance of holding $1,000,000 at the end.
Hard8Dynamic programmingProbabilityNo attempts yetTime limit20sMemory limit512 MBYou have been invited onto the popular TV show "Would you like to be a millionaire?". Of course you would.
The rules are simple.
You are given M, P and X. Compute the probability of ending up with $1000000 or more when you follow the strategy that maximizes your chance of becoming a millionaire.
The first line contains the number of test cases N.
Each of the next N lines holds one test case in the format M P X.
Limits
For each test case print one line in the format Case #c: y.
In the first sample the only way to reach $1000000 is to bet everything on the single round.
In the second sample there is a strategy that still reaches $1000000 after one lost bet. One such strategy is this.