結果

問題 No.895 MESE
ユーザー finefine
提出日時 2019-09-27 22:02:55
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 18 ms / 2,000 ms
コード長 1,069 bytes
コンパイル時間 1,607 ms
コンパイル使用メモリ 167,628 KB
実行使用メモリ 8,432 KB
最終ジャッジ日時 2023-10-24 19:14:42
合計ジャッジ時間 2,559 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
7,764 KB
testcase_01 AC 2 ms
7,764 KB
testcase_02 AC 2 ms
7,764 KB
testcase_03 AC 2 ms
7,764 KB
testcase_04 AC 2 ms
7,764 KB
testcase_05 AC 2 ms
7,764 KB
testcase_06 AC 2 ms
7,764 KB
testcase_07 AC 2 ms
7,764 KB
testcase_08 AC 2 ms
7,776 KB
testcase_09 AC 2 ms
7,772 KB
testcase_10 AC 2 ms
7,776 KB
testcase_11 AC 3 ms
7,780 KB
testcase_12 AC 2 ms
7,772 KB
testcase_13 AC 9 ms
8,432 KB
testcase_14 AC 14 ms
8,432 KB
testcase_15 AC 15 ms
8,432 KB
testcase_16 AC 10 ms
8,432 KB
testcase_17 AC 5 ms
8,432 KB
testcase_18 AC 17 ms
8,432 KB
testcase_19 AC 18 ms
8,432 KB
testcase_20 AC 18 ms
8,432 KB
testcase_21 AC 18 ms
8,432 KB
testcase_22 AC 18 ms
8,432 KB
testcase_23 AC 17 ms
8,432 KB
testcase_24 AC 18 ms
8,432 KB
testcase_25 AC 18 ms
8,432 KB
testcase_26 AC 18 ms
8,432 KB
testcase_27 AC 18 ms
8,432 KB
testcase_28 AC 18 ms
8,432 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

ll modpow(ll x, ll n, ll mod = MOD) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

const int MAXV = 300000;

ll f[MAXV + 1], fi[MAXV + 1];

void init(int n) {
    f[0] = 1;
    for (int i = 1; i <= n; i++) {
        f[i] = f[i-1]*i%MOD;
    }
    fi[n] = modpow(f[n], MOD - 2);
    for (int i = n; i > 0; i--) {
        fi[i-1] = fi[i] * i % MOD;
    }
}

ll comb3(int p, int q, int r) {
    return f[p + q + r] * fi[p] % MOD * fi[q] % MOD * fi[r] % MOD;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    int n = a + b + c;
    init(n);

    ll ans = 0;
    for (int m = n - 2; m >= 1; m--) {
        int aa = a - (n - m - 1);
        if (aa < 0) continue;
        int bb = b - 1;
        (ans += (modpow(2, m) + MOD - 1) % MOD * comb3(aa, bb, c - 1) % MOD) %= MOD;
    }
    cout << ans << "\n";
    return 0;
}
0