Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF -1145141919810
#define REP(i,n) for (int i=0;i<(n);i++)
typedef pair<int,int> P;
int R,C,X,Y,D,L;
int MOD=1000000007;
vector<int> num;
int mod_pow(int i, int j) {
if (j == 0) return 1;
else if (j % 2 == 0) {
int d = mod_pow(i, j / 2)%MOD;
return (d*d)%MOD;
}else return (i*(mod_pow(i, j - 1)%MOD)) % MOD;
}
signed main(){
cin>>R>>C>>X>>Y>>D>>L;
//(X*Y)C(min(D,L))を求める
int hoge1=1,hoge2=1;
for(int i=X*Y;i>((X*Y)-min(D,L));i--){
hoge1*=i;
hoge1%=MOD;
}
for(int i=1;i<=min(D,L);i++){
hoge2*=i;
hoge2%=MOD;
}
int tmp=hoge1*mod_pow(hoge2,MOD-2);
tmp%=MOD;
//R*Cの中のX*Yの位置のパターン
int cnt=0;
for(int i=0;i<R-(X-1);i++) for(int j=0;j<C-(Y-1);j++) cnt++;
cout<<((tmp%MOD)*(cnt%MOD))%MOD<<endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment