LOADING

加载过慢请开启缓存,浏览器默认开启

daily 1

2023/5/3 daily

CF 553 A

ll quick_pow(ll x,ll exp,int p)
{
      ll ans=1;
      while(exp)
      {
        if(exp&1)ans=ans*x%p;
        exp>>=1;
        x=x*x%p;
      }
      return ans;
}
ll inv[MAXN],fac[MAXN];
void init(int n,int p)
{
  memset(inv,0,sizeof(inv));
  memset(fac,0,sizeof(fac));
  inv[0]=fac[0]=1;
  for(int i=1;i<=n;++i)
  {
    fac[i]=fac[i-1]*i%p;
  }
  inv[n]=quick_pow(fac[n],p-2,p)%p;
  for(int i=n;i>=1;--i)inv[i-1]=inv[i]*i%p;
}
ll C(ll n,ll m,ll p)
{
  if(m>n||m<0)return 0;
  return fac[n]*inv[n-m]%p*inv[m]%p;
}
void solve(){
  int k;
  cin>>k;
  ll sum=0;
  vector<int>a(k+1);
  for(int i=1;i<=k;++i){
    cin>>a[i];
    sum+=a[i];
  }
  ll ans=1;
  for(int i=k;i>=1;--i){
    ans*=C(sum-1,a[i]-1,MOD);
    ans%=MOD;
    sum-=a[i];
  }
  cout<<ans<<'\n';
  return;
}