Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define dprint(v) cerr << #v"=" << v << endl //;)
- #define forr(i,a,b) for(int i=(a); i<(b); i++)
- #define forn(i,n) forr(i,0,n)
- #define dforn(i,n) for(int i=n-1; i>=0; i--)
- #define forall(it,v) for(auto it=v.begin();it!=v.end();++it)
- #define sz(c) ((int)c.size())
- #define zero(v) memset(v, 0, sizeof(v))
- #define pb push_back
- #define fst first
- #define snd second
- typedef long long ll;
- typedef pair<int,int> ii;
- const ll MOD = 1e9+7;
- int N,M,P1,P2;
- ll comb[110][110], dp[110][1010];
- int main() {
- //~ freopen("in", "r", stdin);
- ios::sync_with_stdio(0);
- while(cin >> N >> M >> P1 >> P2){
- dp[0][0]=1;
- forr(p,1,1001) dp[0][p]=0;
- forr(x,1,N+1) forn(p,1001) {
- dp[x][p] = 0;
- forr(i,1,min(p,M)+1) {
- dp[x][p] = (dp[x][p]+dp[x-1][p-i])%MOD;
- }
- }
- forn(i, 105){
- comb[i][0]=comb[i][i]=1;
- forr(k, 1, i) comb[i][k]=(comb[i-1][k]+comb[i-1][k-1])%MOD;
- }
- ll ans = 0;
- forn(x,N+1) forn(y,N-x+1) {
- ll aux = (dp[x][P1]*dp[y][P2])%MOD;
- aux = (aux*comb[N][x])%MOD;
- aux = (aux*comb[N-x][y])%MOD;
- //~ cout << x << " " << aux << endl;
- ans = ( ans + aux ) % MOD;
- }
- cout << ans << endl;
- }
- return 0;
- }
Advertisement
RAW Paste Data
Copied
Advertisement