21 lines
579 B
Python
21 lines
579 B
Python
'''
|
|
if p is the probability that the player win, then expectation of banker's income will be
|
|
probability p 1 - p
|
|
income -n 1
|
|
E = 1 - p - pn = 1 - (n + 1)p > 0
|
|
so bonus = n + 1 < 1 / p
|
|
'''
|
|
|
|
def p_trace(loop):
|
|
base = 2
|
|
p_lst = [1]
|
|
for l in range(loop):
|
|
p = 1 / base
|
|
left = list(map(lambda x: x * p, p_lst)) + [0]
|
|
right = [0] + list(map(lambda x: x * (1 - p), p_lst))
|
|
p_lst = list(map(lambda x: x[0] + x[1], zip(left, right)))
|
|
base += 1
|
|
return sum(p_lst[:len(p_lst) // 2])
|
|
|
|
print(int(1 / p_trace(15)))
|