记录编号 202604 评测结果 AAAAAAWWWW
题目名称 [SYOI 2015] Asm_Def排兵布阵 最终得分 60
用户昵称 Gravatarpppoooiiizzy 是否通过 未通过
代码语言 C++ 运行时间 0.478 s
提交时间 2015-11-01 16:20:33 内存使用 31.59 MiB
显示代码纯文本
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<queue>
#include<vector>

const int maxn = 100100;
using namespace std;

#define LL long long
#define MOD 998244353

LL C[2000][2000], f[maxn], n, m, sum, ans = 1;

void get_()
{
    for(int i = 1; i <= 1500; i++) C[i][1] = C[0][i] = 1;
    for(int i = 1; i <= 1500; i++) C[1][i] = i;
    for(int i = 2; i <= 1500; i++)
        for(int j = 2; j <= 1500; j++)
            C[i][j] = (C[i - 1][j] + C[i][j -  1]) % MOD;
}

int main()
{
    freopen("asm_formation.in", "r", stdin);
    freopen("asm_formation.out", "w", stdout);
    ios::sync_with_stdio(false);
    get_();
    cin>>n;
    for(int i = 1; i <= n; i++) cin>>f[i];
    sum = f[1];
    for(int i = 2; i <= n; i++) {
        ans = (ans * C[f[i] - 1][sum + 1]) % MOD;
        sum += f[i];
    }
    cout<<ans<<endl;
    return 0;
}