10105 Polynomial Coefficients 组合数打表

#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
#define N 13
#define MAXD 100 + 10
int C[N][N];
void Get_C(){
    memset(C,0,sizeof(C));
    for(int i = 0; i < N ; i ++){
       C[i][0] = C[i][i] = 1;
       for(int j = 1; j < i ; j++)
        C[i][j] = C[i - 1][j] + C[i-1][j-1];
    }
}
int main(){
    Get_C();
    int k,n;
    while(scanf("%d%d",&n,&k) != EOF){
        int ans = 1;
        int array[MAXD];
        int t = n;
        for(int i = 0; i < k ; i++)
            scanf("%d",&array[i]);
        for(int i = 0; i < k ; i++)
        if(i > 0){
            t = t - array[i - 1];
            ans = ans * C[t][array[i]];
        }
        else if(i == 0){
            ans = ans * C[t][array[i]];
        }
        printf("%d\n",ans);
    }
    return 0;
}

你可能感兴趣的:(10105 Polynomial Coefficients 组合数打表)