Virat and nCr giving tle

i have computed factorial and then use the formula
nCr=(n!) / (r!*(n-r)!) https://ide.codingblocks.com/#/s/24237

ques https://hack.codingblocks.com/contests/c/473/745

Use Lucas Theorem

If this can’t be solved using inverse multiplicative inverse as p here is a prime number?