You are viewing a single comment's thread. Return to all comments →
Python :D
c = 10**9+7 def fact(n): result = 1 while n >= 2: result = ((result)*(n%c))%c n -= 1 return result def fastEXP(base, exp, modulus): base %= modulus result = 1 while exp > 0: if exp & 1: result = (result * base) % modulus base = (base*base)%modulus exp >>= 1 return result def combinations(x,y): amodc = fact(x+y-2) bmodc = fact(x-1)*fact(y-1) return ((amodc%c)*(fastEXP(bmodc, (c-2), c)))%c T = int(input()) for _ in range(T): x, y = map(int, input().split()) print(combinations(y, x))
Seems like cookies are disabled on this browser, please enable them to open this website
Matrix Tracing
You are viewing a single comment's thread. Return to all comments →
Python :D