結果
| 問題 | No.2409 Strange Werewolves | 
| コンテスト | |
| ユーザー |  eve__fuyuki | 
| 提出日時 | 2024-07-09 15:04:28 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 12 ms / 2,000 ms | 
| コード長 | 770 bytes | 
| コンパイル時間 | 2,177 ms | 
| コンパイル使用メモリ | 194,820 KB | 
| 最終ジャッジ日時 | 2025-02-22 02:36:15 | 
| ジャッジサーバーID (参考情報) | judge3 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 16 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
void fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
}
#include <atcoder/modint>
using mint = atcoder::modint998244353;
mint fact[600005], inv[600005];
void init() {
    fact[0] = 1;
    for (int i = 1; i < 600005; i++) fact[i] = fact[i - 1] * i;
    inv[600004] = fact[600004].inv();
    for (int i = 600003; i >= 0; i--) inv[i] = inv[i + 1] * (i + 1);
}
mint nCr(int n, int r) {
    if (r < 0 || r > n) return 0;
    return fact[n] * inv[r] * inv[n - r];
}
int main() {
    fast_io();
    init();
    int x, y, z, w;
    cin >> x >> y >> z >> w;
    if (w == 0) {
        swap(x, y);
        swap(z, w);
    }
    mint ans = x * nCr(y, w) * fact[y - w + x - 1];
    cout << ans.val() << endl;
}
            
            
            
        