Submission #2152295

Source Code Expand

Copy
```#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

long long factorical(int n)
{
long long ans=1,i;
for(i=n;i>1;i--)
ans=(ans*i)%MOD;
return ans;
}

long long beki(long long a,int n)
{
long long s=1LL;
while(n){
if(n%2)s=(s*a)%MOD;
a=(a*a)%MOD;
n/=2;
}
return s;
}

#define MAX_N 2*100005

ll x[MAX_N],invx[MAX_N];

ll ncr(ll a, ll b){
return (x[a] * invx[b] %MOD * invx[a-b])%MOD;

}

int main(void) {
int i,j;
int h,w,a,b;
cin>>h>>w>>a>>b;

ll n=h+w;
x[0]=1;
loop(i,1,n) x[i]=(x[i-1]*i)%MOD;

rep(i,n) invx[i]=beki(x[i],MOD-2);

ll ans=0;
rep(i,h-a){
ans+=(ncr(b-1+i,b-1)*ncr(w-1-b + h-1-i,w-1-b))%MOD;
ans%=MOD;
}
cout<<ans<<endl;
}
```

#### Submission Info

Submission Time 2018-03-04 15:19:37+0900 D - いろはちゃんとマス目 / Iroha and a Grid rika0384 C++14 (GCC 5.4.1) 400 1366 Byte AC 35 ms 3456 KB

#### Test Cases

Set Name Score / Max Score Test Cases
Case Name Status Exec Time Memory