def get(p, q, n):
p = float(p)
q = float(q)
return expectation(p/100, q/100, n, 0)
def expectation(prob, add, target, items = 0, count = -1):
count += 1
if prob >= 1:
# Must get
items += 1
prob = r(1, items)
# print("get: 1")
e = expectation(prob, add, target, items, count)
return e
# not must get
if items != target:
# not end node
# print("get" + str(r(prob, items)))
re = r(prob, items)
win = re*expectation(re, add, target, items+1, count)
# print("miss" + str(1-re))
miss = (1-re)*expectation(prob+add, add, target, items, count)
return win + miss
else:
# end node
# print("endnode" + str(count))
return count
while True:
try:
(p, q, n) = (int(x) for x in raw_input().split())
print(get(p, q, n))
except EOFError:
break
来围观的。朋友刚刚告诉我这道题,稍微写了一下思路(意在清晰,不在优化)。
结果发现不给提交了。
不知道对不对?
E(X2)=E(X3)=...E(Xn),E(X1)单独算。