結果
| 問題 | No.2409 Strange Werewolves | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2025-03-26 02:10:35 | 
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 47 ms / 2,000 ms | 
| コード長 | 808 bytes | 
| コンパイル時間 | 4,122 ms | 
| コンパイル使用メモリ | 275,492 KB | 
| 実行使用メモリ | 5,888 KB | 
| 最終ジャッジ日時 | 2025-03-26 02:10:41 | 
| 合計ジャッジ時間 | 4,974 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 16 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, e) for (int i = (int)(s); i < (int)(e); ++i)
#define all(a) (a).begin(),(a).end()
#include <atcoder/modint>
using namespace atcoder;
using mint = modint998244353;
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    
    ll X, Y, Z, W;
    cin >> X >> Y >> Z >> W;
    
    mint ans = 1;
    if (Z == 0) {
        ll t = X + Y - W;
        rep(i, 1, t) ans *= i;
        ll k = Y - W;
        rep(i, 0, k) ans *= Y - i;
        rep(i, 1, k + 1) ans /= i;
        ans *= X;
    } else {
        ll t = X + Y - Z;
        rep(i, 1, t) ans *= i;
        ll k = X - Z;
        rep(i, 0, k) ans *= X - i;
        rep(i, 1, k + 1) ans /= i;
        ans *= Y;
    }
    
    cout << ans.val() << '\n';
}
            
            
            
        