Test instructions
is to give the total co-possession of k color. Each color has Ki species, arranged must meet the last color of the i+1 type must be at the end of the last color of the first I, other colors arbitrarily. The total number of ways to arrange points together.
Analysis:
If D[i] represents the number of permutations of the first I species, then the number of i+1 is D[i]*c (a[1]+a[2]+). A[I+1]-1,A[I+1]-1); it's good to handle the number of permutations beforehand. Direct calculation.
PS:CF game time is really a bit annoying, say I have been not clear why I watch TV can stick to two points, playing CF will not do? So I just watch TV while playing cf~ haha haha
#include <cstdio>#include <cstring>#include <cmath>#include <iostream>#include <vector>#include <map>#include <algorithm>#define Read Freopen ("Q.in", "R", stdin)#define LL Long Long#define MAXN 1005#define MOD 1000000007using namespace STD;intC[MAXN][MAXN];intA[MAXN];intMain () {intI,j,k; c[1][0]=c[1][1]=1; for(i=2; i<maxn;i++) {c[i][0]=1; for(j=1; j<=i;j++) c[i][j]= (c[i-1][j-1]+c[i-1][J])%mod; }scanf("%d", &k);intx,sum=0; for(i=1; i<=k;i++) {scanf("%d", &a[i]); Sum+=a[i]; } LL res=1; for(i=k;i>1; i--) {res= (res* (LL) c[sum-1][a[i]-1])%mod; Sum-=a[i]; }cout<<res<<endl;}
Codeforces Round #309 (Div. 2) C