记录编号 202582 评测结果 AAAAAAAAAA
题目名称 [SYOI 2015] Asm_Def排兵布阵 最终得分 100
用户昵称 GravatarAsm.Def 是否通过 通过
代码语言 C++ 运行时间 0.032 s
提交时间 2015-11-01 14:48:24 内存使用 7.73 MiB
显示代码纯文本
/***********************************************************************/
/**********************By Asm.Def-Wu Jiaxin*****************************/
/***********************************************************************/
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <algorithm>
using namespace std;
#define SetFile(x) ( freopen(#x".in", "r", stdin), freopen(#x".out", "w", stdout) );
#define UseFREAD
#ifdef UseFREAD
#define getc() *(file_ptr++)
#define FreadLenth 1000000
char CHARPOOL[FreadLenth], *file_ptr = CHARPOOL;
#else
#define getc() getchar() 
#endif
#ifdef DEBUG
#include <ctime>
#endif
template<class T>inline void getd(T &x){
	char ch = getc();bool neg = false;
	while(!isdigit(ch) && ch != '-')ch = getc();
	if(ch == '-')ch = getc(), neg = true;
	x = ch - '0';
	while(isdigit(ch = getc()))x = x * 10 - '0' + ch;
	if(neg)x = -x;
}
/***********************************************************************/
const int maxk = 100003, maxn = 500003, mod = 998244353;
typedef long long LL;

int inv[maxn], fact[maxn], inv_fact[maxn], F[maxk], num[maxk], K;

inline void init(){
	getd(K);
	int S = 0, i, a, b;
	for(i = 1;i <= K;++i)getd(num[i]), S += num[i];
	inv[1] = fact[0] = fact[1] = inv_fact[0] = inv_fact[1] = 1;
	for(i = 2;i <= S;++i){
		fact[i] = (LL)fact[i-1] * i % mod;
		a = mod / i, b = mod - a * i;
		inv[i] = (LL)a * (mod - inv[b]) % mod;
		inv_fact[i] = (LL)inv_fact[i-1] * inv[i] % mod;
	}
}

inline int C(int n, int m){return ((LL)fact[m] * inv_fact[n] % mod) * inv_fact[m - n] % mod;}

inline void work(){
	int Ans = 1, i, S = num[1];
	for(i = 2;i <= K;++i){
		Ans = (LL)Ans * C(S, S + num[i] - 1) % mod;
		S += num[i];
	}
	printf("%d\n", Ans);
}

int main(){

#ifdef DEBUG
	freopen("test.txt", "r", stdin);
#elif !defined ONLINE_JUDGE
	SetFile(asm_formation);
#endif

#ifdef UseFREAD
	fread(file_ptr, 1, FreadLenth, stdin);
#endif

	init();
	work();

#ifdef DEBUG
	printf("\n%.3lf sec \n", (double)clock() / CLOCKS_PER_SEC);
#endif
	return 0;
}