显示代码纯文本
#include <fstream>
#define N 1010
#define M 2010
#define T 9
typedef long long ll;
using namespace std;
int n,m=0;
int num[N]={0};
ll sum[N]={0};
ll C[M+10][T+10]={0};
//ll f[N][M][2]={0};
ll mod=998244353;
ifstream in("asm_formation.in");
ofstream out("asm_formation.out");
void read()
{
int i,j;
in>>n;
for(i=1;i<=n;i++)in>>num[i];
for(i=1;i<=n;i++)sum[i]=sum[i-1]+num[i];
for(i=1;i<=M;i++)
{
C[i][1]=1;
C[1][i]=i;
C[0][i]=1;
}
for(i=2;i<=M;i++)
{
for(j=2;j<=T;j++)
{
C[i][j]=(C[i-1][j]+C[i][j-1])%mod;
}
}
}
void work()
{
int i,x,y;
ll ans=1;
//for(i=1;i<=n;i++)out<<sum[i]<<' ';
for(i=2;i<=n;i++)
{
x=sum[i-1]+1;
y=num[i]-1;
//out<<x<<' '<<y<<endl;
ans*=C[y][x];
ans%=mod;
}
out<<ans<<endl;
}
int main()
{
read();
work();
return 0;
}