UVa 10105 Polynomial Coefficients

UVa 10105 Polynomial Coefficients
以下是我的代码:
#include < stdio.h >
const   long  maxn = 17 ;
long  d[maxn][maxn];
void  init()
{
    
for ( long  i = 0 ;i < maxn;i ++ )
      d[i][
0 ] = d[i][i] = 1 ;
    
for ( long  i = 2 ;i < maxn;i ++ )
      
for ( long  j = 1 ;j < i;j ++ )
        d[i][j]
= d[i - 1 ][j] + d[i - 1 ][j - 1 ];
}
long  C( long  n, long  k)
{
    
return  d[n][k];
}
int  main()
{
    
/*
    freopen("data.in","r",stdin);
    freopen("data.out","w",stdout);
    //
*/
    
long  n,k,ans,a[maxn];
    init();
    
while (scanf( " %ld%ld " , & n, & k) == 2 )
    {
       
for ( long  i = 1 ;i <= k;i ++ ) scanf( " %ld " , & a[i]);
       ans
= 1 ;
       
for ( long  i = 1 ;i <= k;i ++ )
       {
          ans
*= C(n,a[i]);
          n
-= a[i];
       }
       printf(
" %ld\n " ,ans);
    }
return   0 ;
}


你可能感兴趣的:(UVa 10105 Polynomial Coefficients)