結果

問題 No.2409 Strange Werewolves
ユーザー 👑 獅子座じゃない人獅子座じゃない人
提出日時 2023-08-11 21:48:52
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 91 ms / 2,000 ms
コード長 589 bytes
コンパイル時間 1,511 ms
コンパイル使用メモリ 170,664 KB
実行使用メモリ 8,064 KB
最終ジャッジ日時 2024-04-29 12:41:43
合計ジャッジ時間 3,848 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
7,936 KB
testcase_01 AC 88 ms
7,936 KB
testcase_02 AC 89 ms
7,936 KB
testcase_03 AC 87 ms
7,844 KB
testcase_04 AC 88 ms
7,936 KB
testcase_05 AC 88 ms
7,924 KB
testcase_06 AC 88 ms
7,936 KB
testcase_07 AC 88 ms
7,936 KB
testcase_08 AC 88 ms
7,936 KB
testcase_09 AC 89 ms
7,936 KB
testcase_10 AC 89 ms
8,064 KB
testcase_11 AC 88 ms
7,936 KB
testcase_12 AC 91 ms
7,936 KB
testcase_13 AC 88 ms
7,936 KB
testcase_14 AC 88 ms
7,908 KB
testcase_15 AC 87 ms
7,936 KB
testcase_16 AC 87 ms
7,848 KB
testcase_17 AC 88 ms
7,936 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#include <atcoder/modint>
using namespace atcoder;
using mint=modint998244353;

int main(void) {
    constexpr int maxi=6e5;
    int x,y,z,w;
    cin >> x >> y >> z >> w;
    vector<mint> fact(maxi+1,1);
    vector<mint> finv(maxi+1,1);
    for(int i=2;i<=maxi;++i){
        fact[i]=fact[i-1]*i;
        finv[i]=finv[i-1]/i;
    }
    mint ans=fact[x-z+y-w-1];
    if(z==0){
        swap(x,y);
        swap(z,w);
    }
    ans*=fact[x]*finv[z]*finv[x-z];
    ans*=fact[y]*finv[w+1]*finv[y-w-1];
    cout << ans.val() << endl;
    return 0;
}
0