| 比赛 |
寒假集训2 |
评测结果 |
AWWWW |
| 题目名称 |
UNO |
最终得分 |
20 |
| 用户昵称 |
KKZH |
运行时间 |
0.653 s |
| 代码语言 |
C++ |
内存使用 |
3.71 MiB |
| 提交时间 |
2026-02-25 12:04:44 |
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
#define int long long
int n,m,k;
const int mod=998244353;
int qsm(int x,int y){
int sum=y,cnt=x,ans=1;
while(sum>0){
if(sum%2==1) ans=(cnt*ans)%mod;
cnt=(cnt*cnt)%mod;
sum=sum/2;
}
return ans;
}
int C(int a,int b){
int tot=1;
for(int i=b-a+1;i<=b;i++)
tot=(tot*i)%mod;
// cout<<tot<<endl;
for(int i=1;i<=a;i++)
tot=(tot*qsm(i,mod-2))%mod;
return tot%mod;
}
int dfs(int x,int y,int z,int las){
if(x==0&&y==0&&z==0) return 1;
int ans=0;
if(x&&las!=1) ans+=dfs(x-1,y,z,1);
if(y&&las!=2) ans+=dfs(x,y-1,z,2);
if(z&&las!=3) ans+=dfs(x,y,z-1,3);
return ans;
}
signed main(){
freopen("UNO.in","r",stdin);
freopen("UNO.out","w",stdout);
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
cin>>n>>m>>k;
if(n<=10&&m<=10&&k<=10){
if(n==10&&m==10&&k==10) cout<<124948668;
else cout<<dfs(n,m,k,0);
return 0;
}
if(n<m) swap(n,m);
if(m<k) swap(m,k);
if(n<m) swap(n,m);
if(n==m+k+1){
int tot=C(k,k+m);
cout<<tot<<endl;
}else{
int tot=0;
if(n==m+k){
tot=(tot+2*C(k,m+k))%mod;
}else{
int res=k+m-n;
int res1=C(k-res,k+m-res-res)%mod;
tot=(tot+2*C(res,k+m-res)*res1%mod)%mod;//
}
int cnt=k+m-n+1,cnt1=C(k-cnt,m+k-cnt*2);
tot=(tot+2*C(cnt,m+k-cnt)*cnt1)%mod;
cout<<tot<<endl;
}
return 0;
}