| 比赛 |
2025.12.6 |
评测结果 |
TAAAAATTTT |
| 题目名称 |
分组游戏 |
最终得分 |
50 |
| 用户昵称 |
李金泽 |
运行时间 |
5.593 s |
| 代码语言 |
C++ |
内存使用 |
15.07 MiB |
| 提交时间 |
2025-12-06 11:34:27 |
显示代码纯文本
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define N 2005
#define int long long
#define ul unsigned long long
#define db double
#define fo(i,l,r) for(int i=l;i<=r;i++)
#define rf(i,r,l) for(int i=r;i>=l;i--)
using namespace std;
int n,a[N],f[N][N],C[N][N],ans;const int mod=998244353;
void swap(int &x,int &y){int t=x;x=y;y=t;}
int max(int x,int y){return x>y?x:y;}
int min(int x,int y){return x<y?x:y;}
bool cmp(int x,int y){return x>y;}
int add(int x,int y){x+=y;if(x>=mod)x-=mod;return x;}
int read(){
int sum=0;bool f=0;char c=getchar();
for(;c<48||c>57;c=getchar())if(c==45)f=1;
for(;c>=48&&c<=57;c=getchar())sum=sum*10+(c&15);
return f?-sum:sum;
}
signed main(){
freopen("gamem.in","r",stdin);freopen("gamem.out","w",stdout);
n=read();fo(i,1,n)a[i]=read();
sort(a+1,a+n+1,cmp);
C[0][0]=1;
fo(i,1,n)
{
C[i][0]=C[i][i]=1;
fo(j,1,i-1)C[i][j]=add(C[i-1][j],C[i-1][j-1]);
}
f[1][0]=1;
fo(i,1,n-1)
fo(j,0,n)
{
f[i+1][j+1]=add(f[i+1][j+1],f[i][j]);
fo(k,0,min(j,a[i]-1))f[i+1][j-k]=add(f[i+1][j-k],f[i][j]*C[j][k]%mod);
}
fo(i,0,a[n]-1)ans=add(ans,f[n][i]);
printf("%lld",ans);
return 0;
}