You are viewing a single comment's thread. Return to all comments →
you can use the formula for combinations: C(n, k) = n! / (k! * (n-k)!)
from math import factorial for _ in range(int(input())): n,m = map(int,input().split()) print((factorial(n+m)//factorial(n)//factorial(m))%(10**9+7))
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #15: Lattice paths
You are viewing a single comment's thread. Return to all comments →
you can use the formula for combinations: C(n, k) = n! / (k! * (n-k)!)