So You Want to Be a 2ⁿ-aire?
Time limit1sMemory limit128 MB
A contestant with a current prize faces n questions; each question's success chance p is uniform on [t,1]. Find the optimal expected prize, to three decimals.
- Level
Medium7 of 10
- Topics
- Dynamic programming, Probability, Math, Binary search
- Solved
- No attempts yet
Problem
A contestant starts with a prize of $1 and is asked a sequence of questions. For each question, the contestant may:
- quit and keep the current prize;
- answer the question. If the answer is wrong, the contestant quits with nothing. If it is correct, the prize is doubled and the contestant continues to the next question.
After the last question, the contestant quits with the current prize. The contestant wants to maximize the expected prize.
Once a question is asked, the contestant can assess the probability of answering it correctly. For each question, assume is a random variable uniformly distributed over the interval .
Input
The input consists of several lines. Each line contains two numbers: an integer () and a real number (). The input is terminated by a line containing 0 0, which must not be processed.
Output
For each pair and , print the expected prize the contestant earns when playing the optimal strategy, rounded to three decimal places.