結果
| 問題 |
No.2409 Strange Werewolves
|
| コンテスト | |
| ユーザー |
AngrySadEight
|
| 提出日時 | 2023-07-11 14:01:58 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 55 ms / 2,000 ms |
| コード長 | 898 bytes |
| コンパイル時間 | 649 ms |
| コンパイル使用メモリ | 75,616 KB |
| 最終ジャッジ日時 | 2025-02-15 09:45:07 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 16 |
ソースコード
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
ll my_pow(ll x, ll n, ll mod) {
ll ret;
if (n == 0) {
ret = 1;
} else if (n % 2 == 1) {
ret = (x * my_pow((x * x) % mod, n / 2, mod)) % mod;
} else {
ret = my_pow((x * x) % mod, n / 2, mod);
}
return ret;
}
ll inv(ll x, ll mod) { return my_pow(x, mod - 2, mod); }
ll mod = 998244353;
int main() {
ll X, Y, Z, W;
cin >> X >> Y >> Z >> W;
vector<ll> fact(600005);
fact[0] = 1;
for (ll i = 0; i < 600004; i++) {
fact[i + 1] = (fact[i] * (i + 1)) % mod;
}
if (Z == 0) {
swap(X, Y);
swap(Z, W);
}
ll ans =
(fact[X] * ((inv(fact[X - Z], mod) * inv(fact[Z], mod)) % mod)) % mod;
ans = (ans * Y) % mod;
ans = (ans * fact[X + Y - Z - W - 1]) % mod;
cout << ans << endl;
}
AngrySadEight