We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
# Enter your code here. Read input from STDIN. Print output to STDOUTimportsysdefgo():n,k,p=map(int,sys.stdin.readline().split())A=n+1B=k+1res=1f=[1]foriinrange(1,p):f.append(f[-1]*i%p)whileAorB:a,b=A%p,B%pA//= p B//= pifa<b:return0res*=f[a]*pow(f[b]*f[a-b]%p,p-2,p)res%=preturnresfor_inrange(int(sys.stdin.readline())):print(go())
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Ajob Subsequence
You are viewing a single comment's thread. Return to all comments →
Python3 solution