欧拉计划 发表于 2016-8-22 22:41:35

题目121:考察彩色圆盘的游戏

Disc game prize fund

A bag contains one red disc and one blue disc. In a game of chance a player takes a disc at random and its colour is noted. After each turn the disc is returned to the bag, an extra red disc is added, and another disc is taken at random.

The player pays £1 to play and wins if they have taken more blue discs than red discs at the end of the game.

If the game is played for four turns, the probability of a player winning is exactly 11/120, and so the maximum prize fund the banker should allocate for winning in this game would be £10 before they would expect to incur a loss. Note that any payout will be a whole number of pounds and also includes the original £1 paid to play the game, so in the example given the player actually wins £9.

Find the maximum prize fund that should be allocated to a single game in which fifteen turns are played.

题目:

一个包内有一红色圆盘和一蓝色圆盘。游戏中,一个玩家随机拿出一个圆盘,并记录下颜色。每轮游戏结束后,圆盘都要放回包中,并且在包内再放入一红色圆盘,再随机抽取另一圆盘。

要玩儿这个游戏玩家每次需要付费 1 元,如果他们游戏结束时,抽到的蓝色圆盘数比红色圆盘数多的话,则算赢得游戏。

如果这个游戏每次玩四轮,那么玩家获胜的概率是 11/120,所以庄家应该设定的奖金最高应为 10 元,以避免亏损。

注意玩家的最终获利数目是整数,而且包括了起初下注的 1 元。所以,本例中,玩家最终获利 9 元。

请给出在一局 15 轮决胜的游戏中,庄家应设置的最高奖金。

jerryxjr1220 发表于 2016-12-1 21:35:08

解答:
#coding:utf-8
import itertools as it
r = 15
p = list(range(2,r+2))
lose = int((r-1)/2)
t = 0
for l in range(lose+1):
    if l == 0:
      w = 1
      t += w
    else:
      fcom = it.combinations(p,l)
      for each in fcom:
            w = 1
            for e in each:
                w *= (e-1)
            t += w
tt = 1
for j in p:
    tt *= j
print (int(tt/t))
输出:
2269
页: [1]
查看完整版本: 题目121:考察彩色圆盘的游戏