编程介的小学生 2017-03-26 14:23 采纳率: 20.5%
浏览 795
已采纳

So You Want to Be a (2^n)-Aire?

The player starts with a prize of $1, and is asked a sequence of n questions. For each question, he may
quit and keep his prize.
answer the question. If wrong, he quits with nothing. If correct, the prize is doubled, and he continues with the next question.
After the last question, he quits with his prize. The player wants to maximize his expected prize.
Once each question is asked, the player is able to assess the probability p that he will be able to answer it. For each question, we assume that p is a random variable uniformly distributed over the range t .. 1.

Input

Input is a number of lines, each with two numbers: an integer 1 ≤ n ≤ 30, and a real 0 ≤ t ≤ 1. Input is terminated by a line containing 0 0. This line should not be processed.

Output

For each input n and t, print the player's expected prize, if he plays the best strategy. Output should be rounded to three fractional digits.

Sample Input

1 0.5
1 0.3
2 0.6
24 0.25
0 0
Sample Output

1.500
1.357
2.560
230.138

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-04-04 15:22
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)
  • ¥20 matlab yalmip kkt 双层优化问题
  • ¥15 如何在3D高斯飞溅的渲染的场景中获得一个可控的旋转物体
  • ¥88 实在没有想法,需要个思路
  • ¥15 MATLAB报错输入参数太多