結果

問題 No.940 ワープ ε=ε=ε=ε=ε=│;p>д<│
ユーザー noshi91noshi91
提出日時 2019-12-03 01:28:55
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 974 bytes
コンパイル時間 772 ms
コンパイル使用メモリ 69,660 KB
実行使用メモリ 40,536 KB
最終ジャッジ日時 2023-08-18 23:22:34
合計ジャッジ時間 2,087 ms
ジャッジサーバーID
(参考情報)
judge10 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 1 ms
4,380 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>

using ll = long long;
constexpr ll mod = 1000000007;

struct pre {
  std::vector<ll> fact, inv;
  pre(ll n) : fact(n), inv(n) {
    fact[0] = 1;
    for (ll i = 1; i < n; i += 1)
      fact[i] = fact[i - 1] * i % mod;
    inv[n - 1] = 1;
    ll exp = mod - 2, base = fact[n - 1];
    while (exp) {
      if (exp % 2)
        inv[n - 1] = inv[n - 1] * base % mod;
      base = base * base % mod;
      exp /= 2;
    }
    for (ll i = n; --i;)
      inv[i - 1] = inv[i] * i % mod;
  }
  ll c(ll n, ll r) { return fact[n] * inv[r] % mod * inv[n - r] * mod; }
  ll h(ll n, ll r) { return c(n + r - 1, n); }
};

int main() {
  ll x, y, z;
  std::cin >> x >> y >> z;
  ll s = x + y + z + 1;
  pre p(s * 2);
  ll ans = s == 1 ? 1 : 0, coef = 1;
  for (ll k = s; --k;) {
    ans = (ans + coef * p.h(x, k) % mod * p.h(y, k) % mod * p.h(z, k)) % mod;
    coef = (coef * 2 + p.c(s, k) * (s + k & 1 ? mod - 1 : 1)) % mod;
  }
  std::cout << ans;
}
0