結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 7 ms
5,480 KB
testcase_16 AC 18 ms
11,052 KB
testcase_17 AC 32 ms
19,700 KB
testcase_18 AC 41 ms
24,852 KB
testcase_19 AC 32 ms
20,064 KB
testcase_20 AC 52 ms
31,312 KB
testcase_21 AC 22 ms
13,908 KB
testcase_22 AC 49 ms
30,140 KB
testcase_23 AC 19 ms
11,560 KB
testcase_24 AC 51 ms
30,640 KB
testcase_25 AC 60 ms
36,344 KB
testcase_26 AC 68 ms
40,480 KB
権限があれば一括ダウンロードができます

ソースコード

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