Codeforces Round #309 (Div. 2) C

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.