题目大意
解题思路
按颜色添加,显然一定要有一粒在最后,其他的用隔板原理就可以算出。
code
using namespace std;
int const maxs=500000,inf=2147483647;
LL n,fact[maxs+10],refact[maxs+10],mod=998244353;
LL Pow(LL x,LL y){
LL z=1;
for(;y;){
if(y%2)z=z*x%mod;
x=x*x%mod;
y/=2;
}
return z;
}
LL c(LL x,LL y){
return fact[x]*refact[y]%mod*refact[x-y]%mod;
}
int main(){
freopen("d.in","r",stdin);
freopen("d.out","w",stdout);
scanf("%lld",&n);
LL ans=1,sum=0;
fact[0]=refact[0]=1;
fo(i,1,maxs){
fact[i]=fact[i-1]*i%mod;
refact[i]=Pow(fact[i],mod-2);
}
fo(i,1,n){
LL a;scanf("%lld",&a);
ans=ans*c(a-1+sum,sum)%mod;
sum+=a;
}
printf("%lld",ans);
return 0;
}