比赛 寒假集训2 评测结果 AATTT
题目名称 UNO 最终得分 40
用户昵称 梦那边的没好TM 运行时间 3.361 s
代码语言 C++ 内存使用 27.02 MiB
提交时间 2026-02-25 11:20:43
显示代码纯文本
#include<bits/stdc++.h> 
using namespace std;

#define ll long long
#define foru(a,b,c) for(ll a=b;a<=c;a++)
#define p 998244353 

ll n,m,k,f[101][101][101][4];

ll sol(ll a,ll b,ll c,ll lst){
    if(!a&&!b&&!c){
        return 1;
    }
    if(f[a][b][c][lst]!=-1){
        return f[a][b][c][lst];
    }
    ll tmp=0;
    if(lst!=0&&a>0)tmp=(tmp+sol(a-1,b,c,0))%p;
    if(lst!=1&&b>0)tmp=(tmp+sol(a,b-1,c,1))%p;
    if(lst!=2&&c>0)tmp=(tmp+sol(a,b,c-1,2))%p;
    return f[a][b][c][lst]=tmp;
}

int main(){
    freopen("UNO.in","r",stdin);
    freopen("UNO.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin>>n>>m>>k;
    foru(i,0,n){
        foru(j,0,m){
            foru(l,0,k){
                foru(q,0,3){
                    f[i][j][l][q]=-1;
                }
            }
        }
    }
    cout<<sol(n,m,k,3);
    return 0;
}
//c(n,m) n!/(m!(n-m)!)
//1 1 2 6
//1 2 3 10