結果

問題 No.895 MESE
ユーザー 0w10w1
提出日時 2019-09-28 03:50:30
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 28 ms / 2,000 ms
コード長 1,028 bytes
コンパイル時間 2,112 ms
コンパイル使用メモリ 204,504 KB
実行使用メモリ 6,768 KB
最終ジャッジ日時 2023-10-26 01:26:24
合計ジャッジ時間 3,629 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 13 ms
5,448 KB
testcase_14 AC 23 ms
5,448 KB
testcase_15 AC 24 ms
5,712 KB
testcase_16 AC 16 ms
5,184 KB
testcase_17 AC 8 ms
5,184 KB
testcase_18 AC 28 ms
6,768 KB
testcase_19 AC 28 ms
6,768 KB
testcase_20 AC 28 ms
6,768 KB
testcase_21 AC 28 ms
6,768 KB
testcase_22 AC 28 ms
6,768 KB
testcase_23 AC 28 ms
6,768 KB
testcase_24 AC 28 ms
6,768 KB
testcase_25 AC 28 ms
6,768 KB
testcase_26 AC 28 ms
6,768 KB
testcase_27 AC 28 ms
6,768 KB
testcase_28 AC 28 ms
6,768 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

const int MOD = 1e9 + 7;

int main() {
  int A, B, C;
  cin >> A >> B >> C;

  int n = A + B + C;
  vector<int> pow2(n + 1);
  for (int i = pow2[0] = 1; i <= n; ++i) {
    pow2[i] = pow2[i - 1] * 2 % MOD;
  }

  auto ipow = [](int v, int n, int m) {
    int r = 1;
    for (int i = n; i; i >>= 1) {
      if (i & 1) r = 1LL * r * v % m;
      v = 1LL * v * v % m;
    }
    return r;
  };

  vector<int> fac(n + 1);
  for (int i = fac[0] = 1; i <= n; ++i) {
    fac[i] = 1LL * fac[i - 1] * i % MOD;
  }

  vector<int> ifac(n + 1);
  ifac[n] = ipow(fac[n], MOD - 2, MOD);
  for (int i = n; i; --i) {
    ifac[i - 1] = 1LL * ifac[i] * i % MOD;
  }

  int ans = 0;
  for (int i = 1; i <= A; ++i) {
    int a = A - i;
    int b = B - 1;
    int c = C;
    int p = 1LL * fac[a + b + c] * ifac[a] % MOD * ifac[b] % MOD * ifac[c] % MOD;
    (ans += 1LL * (pow2[n - 1 - i] - 1) * ipow(n - i - 1, MOD - 2, MOD) % MOD * c % MOD * p % MOD) %= MOD;
  }

  cout << ans << endl;

  return 0;
}

0