1 条题解

  • 0
    @ 2021-6-15 14:28:50

    C++ :

    #include <cstdio>
    #include <cstring>
    #include <algorithm>
    #include <iostream>
    using namespace std;
    const int MAXN = 150;
    const int MAXK = 20;
    const int MOD = 12345678;
    int dp1[MAXN+10][MAXK+2][MAXK+2], dp2[MAXN+10][MAXK+2][MAXK+2];
    int main(){
        //freopen("party.in", "r" , stdin);
        //freopen("party.out", "w", stdout);
        int n, m, k;
        scanf("%d%d%d", &n, &m, &k);
        int sum = n + m;
        dp1[0][0][0] = 1;
        for(int i=0;i<sum;i++){
            swap(dp1, dp2);
            memset(dp1, 0, sizeof dp1);
            for(int j=0;j<=min(i, m);j++){
                for(int k1=0;k1<=k;k1++){
                    for(int k2=0;k2<=k;k2++){
                        dp1[j+1][max(k1-1, 0)][k2+1] += dp2[j][k1][k2];
                        dp1[j][k1+1][max(k2-1, 0)] += dp2[j][k1][k2];
                        dp1[j][k1][k2] %= MOD;
                    }
                }
            }
        }
        int ans = 0;
        for(int k1=0;k1<=k;k1++){
            for(int k2=0;k2<=k;k2++){
                ans = (ans + dp1[m][k1][k2]) % MOD;
            }
        }
        printf("%d\n", ans);
    
        return 0;
    }
    
    • 1

    信息

    ID
    1007
    时间
    1000ms
    内存
    128MiB
    难度
    (无)
    标签
    递交数
    0
    已通过
    0
    上传者