Demo entry 6351389

DP code

   

Submitted by anonymous on Mar 20, 2017 at 14:14
Language: C++. Code size: 730 Bytes.

#include <iostream>
#include <cstring>
#define N1 101
#define N2 101
#define K1 11
#define K2 11
#define MOD 100000000
using namespace std;

int n1, n2, k1, k2;

long long memo[N1][N2][K1][K2];

long long C(int f, int h, int kf, int kh) {
    if(memo[f][h][kf][kh])
    if(f + h == 0) {
        return 1;
    }
    else {
        long long ans = 0;
        if(f > 0 && kf > 0) {
            ans += C(f - 1, h, kf - 1, k2);
            ans %= MOD;
        }
        if(h > 0 && kh > 0) {
            ans += C(f, h - 1, k1, kh - 1);
            ans %= MOD;
        }
        return ans;
    }
}

int main() {
    cin >> n1 >> n2 >> k1 >> k2;
    cout << C(n1, n2, k1, k2) << endl;
    return 0;
}

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).