比赛 2024暑假C班集训B 评测结果 AAEEE
题目名称 UNO 最终得分 40
用户昵称 darkMoon 运行时间 0.908 s
代码语言 C++ 内存使用 26.92 MiB
提交时间 2024-07-11 11:44:20
显示代码纯文本
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define mp make_pair
using namespace std;
// #define fin cin
// #define fout cout
ifstream fin("UNO.in");
ofstream fout("UNO.out");
auto mread = [](){
    int x;
    fin >> x;
    return x;
};
const int N = 105, MOD = 998244353;
int n = mread(), m = mread(), k = mread(), f[N][N][N][3][2];
signed main(){
    for(int now = 0; now <= 2; now ++){
        for(int l = 0; l <= 1; l ++){
            f[0][0][0][now][l] = 1;
        }
    }
    for(int i = 0; i < n + m + k; i ++){
        for(int a = 0; a <= n && a <= i; a ++){
            for(int b = 0; b <= m && b <= i - a; b ++){
                int c = i - a - b;
                if(c > k){
                    continue;
                }
                for(int now = 0; now <= 2; now ++){
                    for(int l = 0; l <= 1; l ++){
                        if(a < n && now == 0){
                            if(l == 0){
                                (f[a + 1][b][c][(now + 1) % 3][l] += f[a][b][c][now][l]) %= MOD;
                                (f[a + 1][b][c][(now + 2) % 3][!l] += f[a][b][c][now][l]) %= MOD;
                            }
                            else{
                                (f[a + 1][b][c][(now + 2) % 3][l] += f[a][b][c][now][l]) %= MOD;
                                (f[a + 1][b][c][(now + 1) % 3][!l] += f[a][b][c][now][l]) %= MOD;
                            }
                        }
                        if(b < m && now == 1){
                            if(l == 0){
                                (f[a][b + 1][c][(now + 1) % 3][l] += f[a][b][c][now][l]) %= MOD;
                                (f[a][b + 1][c][(now + 2) % 3][!l] += f[a][b][c][now][l]) %= MOD;
                            }
                            else{
                                (f[a][b + 1][c][(now + 2) % 3][l] += f[a][b][c][now][l]) %= MOD;
                                (f[a][b + 1][c][(now + 1) % 3][!l] += f[a][b][c][now][l]) %= MOD;
                            }
                        }
                        if(c < k && now == 2){
                            if(l == 0){
                                (f[a][b][c + 1][(now + 1) % 3][l] += f[a][b][c][now][l]) %= MOD;
                                (f[a][b][c + 1][(now + 2) % 3][!l] += f[a][b][c][now][l]) %= MOD;
                            }
                            else{
                                (f[a][b][c + 1][(now + 2) % 3][l] += f[a][b][c][now][l]) %= MOD;
                                (f[a][b][c + 1][(now + 1) % 3][!l] += f[a][b][c][now][l]) %= MOD;
                            }
                        }
                    }
                }
            }
        }
    }
    // for(int a = 0; a <= n; a ++){
    //     for(int b = 0; b <= m; b ++){
    //         for(int c = 0; c <= k; c ++){
    //             for(int now = 0; now <= 2; now ++){
    //                 for(int l = 0; l <= 1; l ++){
    //                     printf("*** %lld %lld %lld %lld %lld %lld\n", a, b, c, now, l, f[a][b][c][now][l]);
    //                 }
    //             }
    //         }
    //     }
    // }
    int ans = 0;
    for(int now = 0; now <= 2; now ++){
        for(int l = 0; l <= 1; l ++){
            (ans += f[n][m][k][now][l]) %= MOD;
        }
    }
    fout << ans * 748683265ll % MOD;
    return 0;
}