You are viewing a single comment's thread. Return to all comments →
Compact Python 3 solution with built-in pow (performing modular exponentiation) and factorial.
import math q=int(input()) P=10**9+7 for _ in range(q): [n,m]=list(map(int,input().split())) m=m-1 num=math.factorial(n+m)%P den=math.factorial(n)*math.factorial(m) den=pow(den,P-2,P) print((num*den)%P)
Sherlock and Permutations
You are viewing a single comment's thread. Return to all comments →
Compact Python 3 solution with built-in pow (performing modular exponentiation) and factorial.