結果

問題 No.895 MESE
ユーザー pekempeypekempey
提出日時 2019-09-30 18:31:33
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 95 ms / 2,000 ms
コード長 2,458 bytes
コンパイル時間 1,441 ms
コンパイル使用メモリ 169,584 KB
実行使用メモリ 7,304 KB
最終ジャッジ日時 2023-07-26 18:44:37
合計ジャッジ時間 4,038 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 51 ms
5,328 KB
testcase_14 AC 50 ms
5,068 KB
testcase_15 AC 57 ms
5,320 KB
testcase_16 AC 47 ms
5,228 KB
testcase_17 AC 50 ms
5,132 KB
testcase_18 AC 91 ms
7,296 KB
testcase_19 AC 94 ms
7,180 KB
testcase_20 AC 91 ms
7,304 KB
testcase_21 AC 92 ms
7,264 KB
testcase_22 AC 93 ms
7,248 KB
testcase_23 AC 95 ms
7,216 KB
testcase_24 AC 93 ms
7,216 KB
testcase_25 AC 94 ms
7,212 KB
testcase_26 AC 95 ms
7,208 KB
testcase_27 AC 93 ms
7,172 KB
testcase_28 AC 94 ms
7,260 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()

using namespace std;
using ll = long long;

constexpr int MOD = 1000000007;

class mint {
  int n;
public:
  mint(int n_ = 0) : n(n_) {}
  explicit operator int() { return n; }
  friend mint operator-(mint a) { return -a.n + MOD * (a.n != 0); }
  friend mint operator+(mint a, mint b) { int x = a.n + b.n; return x - (x >= MOD) * MOD; }
  friend mint operator-(mint a, mint b) { int x = a.n - b.n; return x + (x < 0) * MOD; }
  friend mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
  friend mint &operator+=(mint &a, mint b) { return a = a + b; }
  friend mint &operator-=(mint &a, mint b) { return a = a - b; }
  friend mint &operator*=(mint &a, mint b) { return a = a * b; }
  friend bool operator==(mint a, mint b) { return a.n == b.n; }
  friend bool operator!=(mint a, mint b) { return a.n != b.n; }
  friend istream &operator>>(istream &i, mint &a) { return i >> a.n; }
  friend ostream &operator<<(ostream &o, mint a) { return o << a.n; }
};
mint operator "" _m(unsigned long long n) { return n; }

vector<mint> F_{1, 1}, R_{1, 1}, I_{0, 1};

void check_fact(int n) {
  for (int i = I_.size(); i <= n; i++) {
    I_.push_back(I_[MOD % i] * (MOD - MOD / i));
    F_.push_back(F_[i - 1] * i);
    R_.push_back(R_[i - 1] * I_[i]);
  }
}

mint I(int n) { check_fact(abs(n)); return n >= 0 ? I_[n] : -I_[-n]; }
mint F(int n) { check_fact(n); return n < 0 ? 0 : F_[n]; }
mint R(int n) { check_fact(n); return n < 0 ? 0 : R_[n]; }
mint C(int n, int r) { return F(n) * R(n - r) * R(r); }
mint P(int n, int r) { return F(n) * R(n - r); }
mint H(int n, int r) { return n == 0 ? (r == 0) : C(n + r - 1, r); }

mint modpow(mint a, long long b) {
  mint res = 1;
  while (b > 0) {
    if (b & 1) res *= a;
    a *= a;
    b >>= 1;
  }
  return res;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int a, b, c; cin >> a >> b >> c;
  int n = a + b + c;
  mint ans;
  for (int i = 2; i < n; i++) {
    mint s = modpow(2, n - 1 - i) * C(n - 1 - i, c - 1);
    // modpow(2, N - 1 - i - 1) * C(N - 2 - i, C - 2);
    // modpow(2, N - 1 - i - 2) * C(N - 2 - i, C - 2);
    // ...
    // modpow(2, 0) * C(N - 2 - i, C - 2);
    s += (modpow(2, n - 1 - i) - 1) * C(n - 2 - i, c - 2);
    ans += s * (C(n - c - 1, b) - C(n - i - c, b));
  }
  cout << ans << endl;
}
0