codeforces553A

sol:很显然的组合数,就是把当前的ai个塞进前面里去

模数是质数也很行

codeforces553A
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
inline ll read()
{
    ll s=0; bool f=0; char ch=' ';
    while(!isdigit(ch)) {f|=(ch=='-'); ch=getchar();}
    while(isdigit(ch)) {s=(s<<3)+(s<<1)+(ch^48); ch=getchar();}
    return (f)?(-s):(s);
}
#define R(x) x=read()
inline void write(ll x)
{
    if(x<0) {putchar('-'); x=-x;}
    if(x<10) {putchar(x+'0'); return;}
    write(x/10); putchar((x%10)+'0');
}
#define W(x) write(x),putchar(' ')
#define Wl(x) write(x),putchar('\n')
const int Mod=1000000007,N=10005;
int n,a[N],b[N],dp[N],jc[N];
inline int ksm(int x,int y)
{
    int s=1,bas=x;
    while(y)
    {
        if(y&1) s=s*bas%Mod;
        bas=bas*bas%Mod;
        y>>=1;
    }
    return s;
}
inline int C(int n,int m)
{
    return jc[n]*ksm(jc[m],Mod-2)%Mod*ksm(jc[n-m],Mod-2)%Mod;
}
signed main()
{
//    freopen("codeforces.in","r",stdin);
    int i,j,k;
    R(n); b[0]=0;
    for(i=1;i<=n;i++)
    {
        R(a[i]);
        b[i]=b[i-1]+a[i];
    }
    dp[1]=1;
    jc[0]=jc[1]=1;
    for(i=2;i<=b[n];i++) jc[i]=jc[i-1]*i%Mod;
    for(i=2;i<=n;i++)
    {
        dp[i]=dp[i-1]*C(b[i]-1,a[i]-1)%Mod;
    }
    Wl(dp[n]);
    return 0;
}
View Code

 

上一篇:tracert路由跟踪命令


下一篇:Tracert命令