結果

問題 No.895 MESE
ユーザー koi_kotyakoi_kotya
提出日時 2019-09-27 22:18:45
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 10 ms / 2,000 ms
コード長 1,636 bytes
コンパイル時間 1,975 ms
コンパイル使用メモリ 169,864 KB
実行使用メモリ 11,048 KB
最終ジャッジ日時 2023-10-24 22:22:16
合計ジャッジ時間 2,934 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
10,716 KB
testcase_01 AC 6 ms
10,716 KB
testcase_02 AC 6 ms
10,720 KB
testcase_03 AC 6 ms
10,716 KB
testcase_04 AC 6 ms
10,716 KB
testcase_05 AC 6 ms
10,716 KB
testcase_06 AC 7 ms
10,716 KB
testcase_07 AC 6 ms
10,716 KB
testcase_08 AC 6 ms
10,720 KB
testcase_09 AC 7 ms
10,724 KB
testcase_10 AC 6 ms
10,724 KB
testcase_11 AC 6 ms
10,724 KB
testcase_12 AC 7 ms
10,720 KB
testcase_13 AC 8 ms
10,716 KB
testcase_14 AC 9 ms
11,048 KB
testcase_15 AC 9 ms
11,048 KB
testcase_16 AC 8 ms
10,784 KB
testcase_17 AC 7 ms
10,784 KB
testcase_18 AC 10 ms
11,048 KB
testcase_19 AC 10 ms
11,048 KB
testcase_20 AC 10 ms
11,048 KB
testcase_21 AC 10 ms
11,048 KB
testcase_22 AC 9 ms
11,048 KB
testcase_23 AC 9 ms
11,048 KB
testcase_24 AC 9 ms
11,048 KB
testcase_25 AC 9 ms
11,048 KB
testcase_26 AC 10 ms
11,048 KB
testcase_27 AC 10 ms
11,048 KB
testcase_28 AC 9 ms
11,048 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
ll const mod = 1e9+7;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

const int MAX_N = 300010;
ll fact[MAX_N],fact_inv[MAX_N],inv[MAX_N];

ll pow_mod(ll a,ll b) {
    ll ret;
    if (b < 0) ret = pow_mod(a,mod+b-1);
    else if (b == 0) ret = 1;
    else if (b == 1) ret = a;
    else {
        ll c = pow_mod(a,b/2);
        if (b%2) ret = (c*c)%mod*a%mod;
        else ret = c*c%mod;
    }
    return ret;
}

void generate_table(int x) {
    fact[0] = 1;fact[1] = 1;
    for (int i = 2;i <= x;++i) fact[i] = fact[i-1]*i%mod;
    fact_inv[x] = pow_mod(fact[x],-1);
    for (int i = x;i > 0;--i) fact_inv[i-1] = fact_inv[i]*i%mod;
    for (int i = 1;i <= x;++i) inv[i] = fact_inv[i]*fact[i-1]%mod;
}

ll combi(ll a, ll b) {
    return fact[a]*fact_inv[b]%mod*fact_inv[a-b]%mod;
}

int main() {
    generate_table(300000);
    int a,b,c;
    cin >> a >> b >> c;
    vector<ll> sum(a+1,0);
    for (int i = 0;i < a;++i) sum[i+1] = fact[a+b+c-3-i]*fact_inv[a-i-1]%mod*fact_inv[b-1]%mod*fact_inv[c-1]%mod;
    for (int i = 0;i < a;++i) (sum[i+1] += sum[i]) %= mod;
    ll ans = 0;
    ll d = 1;
    for (int i = 0;i < a+b+c-2;++i) {
        (ans += d*sum[min(a,a+b+c-i-2)]%mod) %= mod;
        (d *= 2) %= mod;
    }
    cout << ans << endl;
}
0