新农上路
- 积分
- 99
- 大米
- 颗
- 鳄梨
- 个
- 水井
- 尺
- 蓝莓
- 颗
- 萝卜
- 根
- 小米
- 粒
- 学分
- 个
- 注册时间
- 2018-7-30
- 最后登录
- 1970-1-1
|
def dice_game(k):
if k < 0:
raise Exception
expectation = 3.5
for i in range(2, k+1):
stop_rolls = [i for i in range(1, 7) if i > expectation]
expectation = 1/6. * sum(stop_rolls) + (1-len(stop_rolls)/6.) * expectation
return expectation |
|