Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def f(n):
- return 1 if n == 0 else n * f(n - 1)
- def c(n, k):
- return f(n) // f(k) // f(n - k)
- def dp(n, o1, o2, same):
- global zz
- if n == 0:
- return 1 if same >= 37 else 0
- if (n, o1, o2, same) in zz:
- return zz[(n, o1, o2, same)]
- ret = 0
- for i in range(2):
- no1 = o1 - i
- if no1 > n - 1 or no1 < 0:
- continue
- for j in range(2):
- no2 = o2 - j
- if no2 > n - 1 or no2 < 0:
- continue
- ret += dp(n - 1, no1, no2, same + (1 if i == j else 0))
- zz[(n, o1, o2, same)] = ret
- return ret
- zz = {}
- ans = dp(52, 26, 26, 0)
- print(ans)
- allz = c(52, 26)**2
- print(allz)
- print(1. * ans / allz)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement