Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define for0(i, n) for (ll i = 0; i < (int)(n); i++)
- #define for1(i, n) for (ll i = 1; i <= (int)(n); i++)
- #define fast ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
- #define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
- #define MOD 100000000
- #define inf 1e17
- typedef long long ll;
- void dk_98() {
- #ifndef ONLINE_JUDGE
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- #endif
- }
- int n1, n2, k1, k2;
- ll dp[101][2][11][101];
- ll ways(int curr, int type, int succ, int type0) {
- int type1 = curr - type0;
- if (type0 > n1 or type1 > n2) return 0;
- if ((type == 0 and succ > k1) or (type == 1 and succ > k2)) return 0;
- if (type0 == n1 and type1 == n2) return 1;
- if (dp[curr][type][succ][type0] != -1) return dp[curr][type][succ][type0];
- if (type == 0) return dp[curr][type][succ][type0] = (ways(curr + 1, type, succ + 1, type0 + 1) + ways(curr + 1, 1 - type, 1, type0)) % MOD;
- else return dp[curr][type][succ][type0] = (ways(curr + 1, type, succ + 1, type0) + ways(curr + 1, 1 - type, 1, type0 + 1)) % MOD;
- }
- void solve() {
- cin >> n1 >> n2 >> k1 >> k2;
- memset(dp, -1, sizeof(dp));
- ll term1 = ways(1, 0, 1, 1);
- ll term2 = ways(1, 1, 1, 0);
- cout << (term1 + term2) % MOD;
- }
- int main() {
- fast;
- dk_98();
- int t = 1; //cin >> t;
- while (t--) {
- solve();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement