結果

問題 No.2409 Strange Werewolves
ユーザー rlangevinrlangevin
提出日時 2023-08-11 23:04:04
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 549 bytes
コンパイル時間 241 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 74,240 KB
最終ジャッジ日時 2024-04-29 14:14:38
合計ジャッジ時間 2,109 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 61 ms
65,792 KB
testcase_01 AC 60 ms
65,920 KB
testcase_02 AC 60 ms
66,048 KB
testcase_03 RE -
testcase_04 AC 60 ms
66,176 KB
testcase_05 AC 60 ms
66,176 KB
testcase_06 RE -
testcase_07 AC 60 ms
66,176 KB
testcase_08 AC 60 ms
66,048 KB
testcase_09 AC 59 ms
66,048 KB
testcase_10 AC 59 ms
65,920 KB
testcase_11 AC 60 ms
66,304 KB
testcase_12 AC 59 ms
66,176 KB
testcase_13 AC 60 ms
65,792 KB
testcase_14 AC 60 ms
65,920 KB
testcase_15 AC 60 ms
66,048 KB
testcase_16 AC 60 ms
66,176 KB
testcase_17 AC 60 ms
65,792 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

X, Y, Z, W = map(int, input().split())
mod = 998244353
a, b = X - Z, Y - W

n = 505050
fact = [1] * (n + 1)
invfact = [1] * (n + 1)
for i in range(1, n):
    fact[i + 1] = ((i+1) * fact[i]) % mod
invfact[n] = pow(fact[n], mod - 2, mod)
for i in range(n - 1, -1, -1):
    invfact[i] = invfact[i + 1] * (i + 1) % mod

def comb(n, r):
    if n < 0 or r < 0 or n - r < 0:
        return 0
    return fact[n] * invfact[r] * invfact[n - r] % mod


ans = comb(X, Z) * comb(Y, W) * fact[a+b-1] % mod
if Z == 0:
    ans *= X
else:
    ans *= Y
print(ans%mod)
0