結果

問題 No.895 MESE
ユーザー 438kujira438kujira
提出日時 2019-10-03 22:56:13
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 89 ms / 2,000 ms
コード長 1,360 bytes
コンパイル時間 1,739 ms
コンパイル使用メモリ 166,032 KB
実行使用メモリ 8,076 KB
最終ジャッジ日時 2024-04-14 09:44:39
合計ジャッジ時間 4,247 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
7,936 KB
testcase_01 AC 7 ms
7,848 KB
testcase_02 AC 8 ms
7,936 KB
testcase_03 AC 8 ms
7,936 KB
testcase_04 AC 8 ms
7,936 KB
testcase_05 AC 8 ms
7,936 KB
testcase_06 AC 7 ms
7,884 KB
testcase_07 AC 7 ms
7,880 KB
testcase_08 AC 8 ms
7,936 KB
testcase_09 AC 7 ms
7,936 KB
testcase_10 AC 8 ms
7,880 KB
testcase_11 AC 8 ms
7,868 KB
testcase_12 AC 9 ms
7,936 KB
testcase_13 AC 36 ms
7,936 KB
testcase_14 AC 77 ms
7,920 KB
testcase_15 AC 81 ms
7,936 KB
testcase_16 AC 52 ms
7,980 KB
testcase_17 AC 14 ms
7,856 KB
testcase_18 AC 87 ms
8,076 KB
testcase_19 AC 87 ms
7,860 KB
testcase_20 AC 89 ms
7,856 KB
testcase_21 AC 88 ms
7,972 KB
testcase_22 AC 88 ms
7,936 KB
testcase_23 AC 89 ms
7,936 KB
testcase_24 AC 88 ms
7,944 KB
testcase_25 AC 88 ms
7,888 KB
testcase_26 AC 89 ms
8,064 KB
testcase_27 AC 89 ms
7,936 KB
testcase_28 AC 89 ms
8,064 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl


#define MAX_N 300005
ll factorial[MAX_N];
void make_factorial_tableMOD(){
    factorial[0] = 1;
    for(int i = 1; i < MAX_N; i++){
        factorial[i] = factorial[i-1]*i%MOD;
    }
}

ll bisection_powerMOD(ll x,ll y){
    if(y==0)        { return 1; }
    ll t = bisection_powerMOD(x*x%MOD,y/2);
    if(y%2==1)      { t = t*x%MOD; }
    return t;
}

ll nCrMOD(ll n, ll r){
    if(n==0){return 1;}
    if(n<r || n<=0 || r<0){return 0;}
    ll a = factorial[n];
    ll b = a*bisection_powerMOD(factorial[r],(MOD-2))%MOD;
    ll c = b*bisection_powerMOD(factorial[n-r],MOD-2)%MOD;
    return c % MOD;
}

int main(){
    ll a, b, c;
    cin >> a >> b >> c;

    make_factorial_tableMOD();
    ll ans = 0;
    vector<ll> pow2(MAX_N,1);
    ll t = 1;
    for(int i = 1; i < MAX_N; i++){
        t *= 2;
        t %= MOD;
        pow2[i] = t;
    }
    for(int i = 1; i <= a; i++){
        ll tmp = nCrMOD(a+b+c-i-2,c-1)*nCrMOD(a+b-i-1,b-1);
        tmp %= MOD;
        tmp *= (pow2[a+b+c-i-1]-1);
        tmp %= MOD;
        ans += tmp;
        ans %= MOD;
    }
    cout << ans % MOD << endl;
    return 0;
}
0