正题
题目链接:http://10.156.31.134/contestnew.aspx?cid=189
题目大意
nnn种物品,每种aia_iai个。放进kkk个有序盒子求方案数(可以不放完)
解题思路
不放完其实就是k+1k+1k+1个盒子,插板法求Ck+aiaiC_{k+a_i}^{a_i}Ck+aiai,即使kkk很大但是aia_iai很小,预处理即可
codecodecode
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
const ll XJQ=998244353;
ll n,k,f[110];
ll power(ll x,ll b){x%=XJQ;ll ans=1;while(b){if(b&1)ans=ans*x%XJQ;x=x*x%XJQ;b>>=1;}return ans;
}
int main()
{scanf("%lld%lld",&n,&k);ll z=1,inv=1;f[0]=1;for(ll i=1;i<=100;i++){z=z*((k+i)%XJQ)%XJQ;inv=inv*power(i,XJQ-2)%XJQ;f[i]=z*inv%XJQ;}ll ans=1;for(ll i=1;i<=n;i++){ll x;scanf("%lld",&x);ans=ans*f[x]%XJQ;}printf("%lld",ans);
}