Skip to content

Instantly share code, notes, and snippets.

@bokuo-okubo
Created July 11, 2016 12:01
Show Gist options
  • Save bokuo-okubo/7a8052671be9df30dcaaa3dc0a09797a to your computer and use it in GitHub Desktop.
Save bokuo-okubo/7a8052671be9df30dcaaa3dc0a09797a to your computer and use it in GitHub Desktop.
# coding: utf-8
def func(n, m, N):
def state(cnt, acc):
if N == cnt:
return acc
else:
return state(cnt + 1, (1 - 1/n - 1/m) * acc + 1/m)
return state(0, 1)
def generalize(n, m, N):
alph = (n / (n + m))
if N == 0:
return 1.0
else:
return alph + (1 - alph) * pow(1 - 1/n - 1/m, N)
if __name__ == '__main__':
n, m, N = [float(num) for num in raw_input().split(' ')]
print generalize(n, m, N)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment