結果

問題 No.1044 正直者大学
ユーザー auauaauaua
提出日時 2020-05-02 03:11:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 473 ms / 2,000 ms
コード長 1,815 bytes
コンパイル時間 1,539 ms
コンパイル使用メモリ 168,184 KB
実行使用メモリ 51,500 KB
最終ジャッジ日時 2023-08-26 22:06:35
合計ジャッジ時間 18,188 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 454 ms
50,288 KB
testcase_01 AC 452 ms
50,472 KB
testcase_02 AC 458 ms
50,232 KB
testcase_03 AC 460 ms
50,300 KB
testcase_04 AC 473 ms
50,236 KB
testcase_05 AC 458 ms
51,500 KB
testcase_06 AC 472 ms
51,448 KB
testcase_07 AC 463 ms
50,188 KB
testcase_08 AC 467 ms
50,292 KB
testcase_09 AC 466 ms
50,236 KB
testcase_10 AC 472 ms
50,284 KB
testcase_11 AC 467 ms
50,232 KB
testcase_12 AC 470 ms
50,844 KB
testcase_13 AC 467 ms
50,884 KB
testcase_14 AC 470 ms
50,708 KB
testcase_15 AC 470 ms
51,240 KB
testcase_16 AC 469 ms
51,260 KB
testcase_17 AC 457 ms
50,364 KB
testcase_18 AC 472 ms
50,620 KB
testcase_19 AC 462 ms
50,412 KB
testcase_20 AC 465 ms
50,300 KB
testcase_21 AC 464 ms
50,180 KB
testcase_22 AC 460 ms
50,440 KB
testcase_23 AC 458 ms
51,248 KB
testcase_24 AC 466 ms
50,720 KB
testcase_25 AC 454 ms
50,676 KB
testcase_26 AC 465 ms
51,056 KB
testcase_27 AC 458 ms
50,380 KB
testcase_28 AC 456 ms
50,244 KB
testcase_29 AC 454 ms
50,224 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
//Combination
long long extGCD(long long a,long long mod,long long &x,long long &y){
    if(mod==0){
        x=1;
        y=0;
        return a;
    }
    long long d=extGCD(mod,a%mod,y,x);
    y-=(a/mod)*x;
    return d;
}
long long invmod(long long a,long long mod){
    long long x,y;
    extGCD(a,mod,x,y);
    x%=mod;
    if(x<0)x+=mod;
    return x;
}
ll fac[2000010],finv[2000010],inv[2000010];
void combinit(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    REP(i,2,2000010){
        fac[i]=fac[i-1]*i%mod;
        inv[i]=invmod(i,mod);
        finv[i]=finv[i-1]*inv[i]%mod;
    }
}
ll comb(ll n,ll k){
    if(n<k)return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}
ll rui(ll a,ll b){
    ll res=1;
    ll x=a;
    while(b){
        if(b&1)res=res*x%mod;
        x=x*x%mod;
        b/=2;
    }
    return res;
}
signed main(){
    ll n,m,k;cin>>n>>m>>k;
    combinit();
    ll d=n+m;
    vector<ll>kai(d+1);
    kai[0]=1;
    REP(i,1,d+1){
        kai[i]=kai[i-1]*i%mod;
    }
    ll ans=0;
    rep(i,n+m+1){
        if(i%2)continue;
        if(n+m-i<k)continue;
        ll res=1;
        ll c=(i)/2;
        if(c>m)continue;
        res=res*comb(n,c)%mod;
        res=res*comb(m-1,c-1)%mod;
        res=res*kai[n-1]%mod;
        res=res*kai[m]%mod;
        ans=(ans+res)%mod;
    }
    if(ans<0)ans+=mod;
    cout<<ans<<endl;
}
0