Skip to content

Instantly share code, notes, and snippets.

@asuka-mirai
Created September 17, 2017 06:45
Show Gist options
  • Save asuka-mirai/64313e50d19906d121e671be912e07db to your computer and use it in GitHub Desktop.
Save asuka-mirai/64313e50d19906d121e671be912e07db to your computer and use it in GitHub Desktop.
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