Another  Way  to  find  NcR  using  higher  Secondary school  formula :P


void pre()
{
    for(int i=0;i<=4000;i++)
        nCr[i][0] = 1 ;
    for(int i=1;i<=4000;i++)
        for(int j=1;j<=i;j++)
            nCr[i][j] = ( nCr[i-1][j-1] + nCr[i-1][j] ) % MOD ;
}

Comments

Popular posts from this blog

Getting Started With MEAN App Development with AngularJs , ExpressJs , NodeJs and MongoDB.

B. Dreamoon and WiFi :calculate no. of ways : recursive solution (branch and bound )

A. Dreamoon and Stairs : minimum steps to reach : recursion solution.