10105

求多项式(x1+x2+x3+...xk)n展开式的某一项x1n1x2n2*...xknk的系数:

组合的知识:结果为n!/(n1!n2!...nk!)

//============================================================================
// Name        : 10105.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
using namespace std;

long long jie[15] = {1,1,2,6,24,120,720,5040,40320,362880,3628800,39916800,479001600};
long long ans;
int t, n, k;

int main() {
	while(scanf("%d%d", &n, &k)!=EOF){
		ans = jie[n];
		for(int i = 0;i < k;i++){
			scanf("%d", &t);
			ans/=jie[t];
		}
		printf("%lld\n", ans);
	}
	return 0;
}

posted @ 2011-05-25 16:14  KOKO's  阅读(5568)  评论(0编辑  收藏  举报