Created
September 17, 2017 06:45
-
-
Save asuka-mirai/64313e50d19906d121e671be912e07db to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
W, H = map(int, input().split()) | |
C = int(1e9)+7 | |
fact = [1] | |
for x in range(1, H+W-1): | |
fact.append( (x * fact[x-1]) % C ) | |
factinv = [1] * (H+W-1) | |
factinv[H+W-2] = pow(fact[H+W-2], C-2, C) | |
for x in reversed(range(2, H+W-2)): | |
factinv[x] = (factinv[x+1] * (x+1)) % C | |
def nCr(n, r): | |
return (fact[n] * factinv[r] * factinv[n-r]) % C | |
print(nCr(H+W-2, H-1)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment