結果

問題 No.895 MESE
ユーザー face4face4
提出日時 2019-10-06 11:15:53
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 9 ms / 2,000 ms
コード長 1,280 bytes
コンパイル時間 2,022 ms
コンパイル使用メモリ 67,324 KB
実行使用メモリ 8,268 KB
最終ジャッジ日時 2023-07-30 18:05:28
合計ジャッジ時間 2,270 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,376 KB
testcase_01 AC 3 ms
5,428 KB
testcase_02 AC 2 ms
5,420 KB
testcase_03 AC 2 ms
5,384 KB
testcase_04 AC 2 ms
5,392 KB
testcase_05 AC 3 ms
5,476 KB
testcase_06 AC 2 ms
5,380 KB
testcase_07 AC 2 ms
5,416 KB
testcase_08 AC 2 ms
5,408 KB
testcase_09 AC 2 ms
5,392 KB
testcase_10 AC 3 ms
5,500 KB
testcase_11 AC 2 ms
5,416 KB
testcase_12 AC 2 ms
5,516 KB
testcase_13 AC 6 ms
6,768 KB
testcase_14 AC 6 ms
6,732 KB
testcase_15 AC 7 ms
7,076 KB
testcase_16 AC 5 ms
6,664 KB
testcase_17 AC 5 ms
6,692 KB
testcase_18 AC 9 ms
8,080 KB
testcase_19 AC 9 ms
8,060 KB
testcase_20 AC 9 ms
8,040 KB
testcase_21 AC 9 ms
8,028 KB
testcase_22 AC 9 ms
8,268 KB
testcase_23 AC 9 ms
8,144 KB
testcase_24 AC 9 ms
8,200 KB
testcase_25 AC 8 ms
8,140 KB
testcase_26 AC 9 ms
8,032 KB
testcase_27 AC 9 ms
8,036 KB
testcase_28 AC 9 ms
8,032 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
using namespace std;

typedef long long ll;
const ll mod = 1e9 + 7;

ll modpow(ll a, ll b, ll p = 1e9+7){
    if(b == 0)  return 1;

    if(b % 2 == 0){
        ll d = modpow(a, b/2, p);
        return (d*d) % p;
    }else{
        return (a%p * modpow(a, b-1, p)) % p;
    }
}

ll po[300001], inv[300001];
void init(ll N){
    po[0] = 1;
    for(int i = 1; i < N; i++)  po[i] = (po[i-1] * i) % mod;
    inv[N-1] = modpow(po[N-1], mod-2, mod);
    for(int i = N-2; i >= 0; i--)   inv[i] = (inv[i+1] * (i+1)) % mod;
}

ll nCk(ll n, ll k){
    if(k == 0)  return 1;
    if(n < k)   return 0;
    return (((po[n]*inv[n-k])%mod)*inv[k])%mod;
}

ll nPk(ll n, ll k){
    if(k == 0)  return 1;
    if(n < k)   return 0;
    return (po[n]*inv[n-k])%mod;
}

ll nHk(ll n, ll k){
    if(n == 0 && k == 0)    return 1;
    return nCk(n+k-1, k-1);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b, c;
    cin >> a >> b >> c;
    init(a+b+c+1);
    ll ans = 0, beki = (modpow(2,a+b+c-1)-1+mod)%mod, twoinv = modpow(2, mod-2);
    for(ll i = 1; i <= a; i++){
        beki = (beki-1+mod)*twoinv%mod;
        ans += nCk(a+b+c-i-2, c-1)*nCk(a+b-i-1, b-1)%mod*beki%mod;
        ans %= mod;
    }
    cout << ans << "\n";
    return 0;
}
0