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
Task D - いろはちゃんとマス目 / Iroha and a Grid
User rika0384
Language C++14 (GCC 5.4.1)
Score 400
Code Size 1366 Byte
Status
Exec Time 35 ms
Memory 3456 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 subtask0_01.txt, subtask0_02.txt, subtask0_03.txt, subtask0_04.txt
All 400 / 400 subtask0_01.txt, subtask0_02.txt, subtask0_03.txt, subtask0_04.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_max.txt, subtask2_01.txt, subtask2_02.txt, subtask2_03.txt, subtask2_04.txt, subtask2_05.txt, subtask2_06.txt, subtask2_07.txt, subtask2_08.txt, subtask2_09.txt, subtask2_10.txt, subtask2_max.txt
Case Name Status Exec Time Memory
subtask0_01.txt 1 ms 256 KB
subtask0_02.txt 1 ms 256 KB
subtask0_03.txt 34 ms 3328 KB
subtask0_04.txt 34 ms 3328 KB
subtask1_01.txt 1 ms 256 KB
subtask1_02.txt 1 ms 256 KB
subtask1_03.txt 1 ms 256 KB
subtask1_04.txt 1 ms 256 KB
subtask1_05.txt 1 ms 256 KB
subtask1_06.txt 1 ms 256 KB
subtask1_07.txt 1 ms 256 KB
subtask1_08.txt 1 ms 256 KB
subtask1_09.txt 1 ms 256 KB
subtask1_10.txt 1 ms 256 KB
subtask1_max.txt 1 ms 256 KB
subtask2_01.txt 4 ms 512 KB
subtask2_02.txt 4 ms 512 KB
subtask2_03.txt 3 ms 384 KB
subtask2_04.txt 4 ms 512 KB
subtask2_05.txt 3 ms 512 KB
subtask2_06.txt 35 ms 3328 KB
subtask2_07.txt 34 ms 3328 KB
subtask2_08.txt 35 ms 3328 KB
subtask2_09.txt 35 ms 3328 KB
subtask2_10.txt 34 ms 3456 KB
subtask2_max.txt 5 ms 512 KB