結果

問題 No.2409 Strange Werewolves
ユーザー kinapharkinaphar
提出日時 2023-08-11 23:37:59
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,418 bytes
コンパイル時間 1,607 ms
コンパイル使用メモリ 166,492 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-29 14:50:00
合計ジャッジ時間 2,741 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 WA -
testcase_02 AC 2 ms
5,376 KB
testcase_03 WA -
testcase_04 WA -
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 -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
#define I_MAX 2147483647;
#define LL_MAX 9223372036854775806;

#define OVERLOAD_REP(_1, _2, _3, name, ...) name
#define REP1(i, n) for (auto i = std::decay_t<decltype(n)>{}; (i) != (n); ++(i))
#define REP2(i, l, r) for (auto i = (l); (i) != (r); ++(i))
#define rep(...) OVERLOAD_REP(__VA_ARGS__, REP2, REP1)(__VA_ARGS__)

int main() {
  ll x, y, z, w;
  ll ans = 1;
  ll m = 998244353;

  cin >> x >> y >> z >> w;

  // ll a = x - z;                 // 人間追放数.
  // ll b = y - w;                 // 狼追放数.

  for (ll i = x; i > z; i--) {  // 人間すべて 〜 人間残り.
    ans *= i;
    ans %= m;
  }
  for (ll i = x - z; i > 1; i--) {  // 人間追放数! で割る.
    ans /= i;
  }
  // cout << ans << endl;

  for (ll i = y; i > w; i--) {  // 狼すべて 〜 狼残り.
    ans *= i;
    ans %= m;
  }
  for (ll i = y - w; i > 1; i--) {  // 狼追放数! で割る.
    ans /= i;
  }
  // cout << ans << endl;

  for (ll i = (x - z) + (y - w); i > 1;
       i--) {  // 追放の合計数!、最初だけ「残り0人」のほう.
    if (i == (x - z) + (y - w)) {
      if (z == 0) {
        ans *= (x - z);
        ans %= m;
      } else if (w == 0) {
        ans *= (y - w);
        ans %= m;
      }
    } else {
      ans *= i;
      ans %= m;
    }
  }
  cout << ans << endl;
}
0