結果

問題 No.2409 Strange Werewolves
ユーザー rlangevinrlangevin
提出日時 2023-08-11 23:04:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 75 ms / 2,000 ms
コード長 550 bytes
コンパイル時間 186 ms
コンパイル使用メモリ 81,792 KB
実行使用メモリ 73,856 KB
最終ジャッジ日時 2024-04-29 14:15:01
合計ジャッジ時間 2,286 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
73,728 KB
testcase_01 AC 75 ms
73,600 KB
testcase_02 AC 75 ms
73,728 KB
testcase_03 AC 71 ms
73,856 KB
testcase_04 AC 72 ms
73,856 KB
testcase_05 AC 70 ms
73,856 KB
testcase_06 AC 72 ms
73,728 KB
testcase_07 AC 72 ms
73,728 KB
testcase_08 AC 72 ms
73,728 KB
testcase_09 AC 72 ms
73,856 KB
testcase_10 AC 72 ms
73,472 KB
testcase_11 AC 73 ms
73,856 KB
testcase_12 AC 72 ms
73,600 KB
testcase_13 AC 72 ms
73,856 KB
testcase_14 AC 72 ms
73,600 KB
testcase_15 AC 72 ms
73,856 KB
testcase_16 AC 72 ms
73,728 KB
testcase_17 AC 72 ms
73,600 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

n = 10**6+5
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