You are viewing a single comment's thread. Return to all comments →
Actually the answer is
and the forumula
now you can apply dp you may take help of this function as
it is little bit tuff for me to understand c# that's why iam writing this function
for (i = 0; i <= n; i++)
for (j = 0; j <= k; j++)
if (j == 0 || j == i)//as nc0=ncn=1;
C[i][j] = 1;
C[i][j] = ((C[i-1][j-1])%mod +( C[i-1][j])%mod)%mod;
now you can return the desired answer .
Now in your code this line
result = (topfact / (belowfact1 * belowfact2))%1000000007;
will get run-time error or tle as your modulus approach formula is not correct as
(a * b) % mod = ((a % mod) * (b % mod)) % mod,
(a / b ) % mod = ((a % mod) * (b^-1 % mod)) % mod,
and one more reason is that the
(topfact / (belowfact1*belowfact2))
will not work properly .
if problem persist then feel free to contact for further
clarification or you may take help of my c code
k means m..?