Submission #7473627


Source Code Expand

Copy
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
ll modinv(ll a, ll m) {
    ll b=m,u=1,v=0;
    while(b){
        ll t = a/b;
        a -= t*b; swap(a,b);
        u -= t*v; swap(u,v);
    }
    u %= m;
    if (u<0) u += m;
    return u;
}
vector<ll> kaijou(1000001);
ll comb(int x,int y){
    if(x<y || y<0)  return 0;
    return kaijou[x]*modinv(kaijou[x-y]*kaijou[y],MOD)%MOD;
}
int main(){
    kaijou[0]=1;
    rep(i,1000000) kaijou[i+1]=(kaijou[i]*(i+1))%MOD;
    
    int r,c,x,y,d,l;
    cin>>r>>c>>x>>y>>d>>l;
    
    ll ans=(comb(x*y,d)*comb(x*y-d,l))%MOD;
    ans-=(comb((x-1)*(y-1),d)*comb((x-1)*(y-1)-d,l))%MOD;
    ans=(ans+MOD)%MOD;
    ans*=(r-x+1)*(c-y+1);
    ans%=MOD;
    cout<<ans<<endl;
}

Submission Info

Submission Time
Task D - AtCoder社の冬
User gyouzasushi
Language C++14 (GCC 5.4.1)
Score 100
Code Size 1096 Byte
Status
Exec Time 9 ms
Memory 8064 KB

Judge Result

Set Name Score / Max Score Test Cases
sub 100 / 100 00_sample_01E.txt, 00_sample_02E.txt, 00_sample_03E.txt, test_03E.txt, test_04E.txt, test_07E.txt, test_08E.txt, test_11E.txt, test_12E.txt, test_15E.txt, test_16E.txt, test_19E.txt, test_20E.txt, test_23E.txt, test_24E.txt, test_27E.txt, test_28E.txt, test_31E.txt, test_32E.txt, test_36E.txt, test_37E.txt, test_38E.txt, test_39E.txt, test_45E.txt, test_47E.txt
All 0 / 1 00_sample_01E.txt, 00_sample_02E.txt, 00_sample_03E.txt, 00_sample_04.txt, test_01.txt, test_02.txt, test_03E.txt, test_04E.txt, test_05.txt, test_06.txt, test_07E.txt, test_08E.txt, test_09.txt, test_10.txt, test_11E.txt, test_12E.txt, test_13.txt, test_14.txt, test_15E.txt, test_16E.txt, test_17.txt, test_18.txt, test_19E.txt, test_20E.txt, test_21.txt, test_22.txt, test_23E.txt, test_24E.txt, test_25.txt, test_26.txt, test_27E.txt, test_28E.txt, test_29.txt, test_30.txt, test_31E.txt, test_32E.txt, test_33.txt, test_34.txt, test_35.txt, test_36E.txt, test_37E.txt, test_38E.txt, test_39E.txt, test_40.txt, test_41.txt, test_42.txt, test_43.txt, test_44.txt, test_45E.txt, test_46.txt, test_47E.txt, test_48.txt
Case Name Status Exec Time Memory
00_sample_01E.txt 8 ms 8064 KB
00_sample_02E.txt 8 ms 8064 KB
00_sample_03E.txt 8 ms 8064 KB
00_sample_04.txt 8 ms 8064 KB
test_01.txt 8 ms 8064 KB
test_02.txt 8 ms 8064 KB
test_03E.txt 8 ms 8064 KB
test_04E.txt 8 ms 8064 KB
test_05.txt 8 ms 8064 KB
test_06.txt 9 ms 8064 KB
test_07E.txt 9 ms 8064 KB
test_08E.txt 8 ms 8064 KB
test_09.txt 8 ms 8064 KB
test_10.txt 8 ms 8064 KB
test_11E.txt 8 ms 8064 KB
test_12E.txt 8 ms 8064 KB
test_13.txt 9 ms 8064 KB
test_14.txt 8 ms 8064 KB
test_15E.txt 9 ms 8064 KB
test_16E.txt 8 ms 8064 KB
test_17.txt 8 ms 8064 KB
test_18.txt 8 ms 8064 KB
test_19E.txt 8 ms 8064 KB
test_20E.txt 9 ms 8064 KB
test_21.txt 8 ms 8064 KB
test_22.txt 8 ms 8064 KB
test_23E.txt 8 ms 8064 KB
test_24E.txt 8 ms 8064 KB
test_25.txt 8 ms 8064 KB
test_26.txt 8 ms 8064 KB
test_27E.txt 8 ms 8064 KB
test_28E.txt 8 ms 8064 KB
test_29.txt 8 ms 8064 KB
test_30.txt 8 ms 8064 KB
test_31E.txt 8 ms 8064 KB
test_32E.txt 8 ms 8064 KB
test_33.txt 8 ms 8064 KB
test_34.txt 8 ms 8064 KB
test_35.txt 9 ms 8064 KB
test_36E.txt 8 ms 8064 KB
test_37E.txt 8 ms 8064 KB
test_38E.txt 8 ms 8064 KB
test_39E.txt 9 ms 8064 KB
test_40.txt 8 ms 8064 KB
test_41.txt 8 ms 8064 KB
test_42.txt 8 ms 8064 KB
test_43.txt 8 ms 8064 KB
test_44.txt 8 ms 8064 KB
test_45E.txt 8 ms 8064 KB
test_46.txt 8 ms 8064 KB
test_47E.txt 8 ms 8064 KB
test_48.txt 9 ms 8064 KB