結果

問題 No.2409 Strange Werewolves
ユーザー ryohei22
提出日時 2023-08-12 01:34:39
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 53 ms / 2,000 ms
コード長 437 bytes
コンパイル時間 309 ms
コンパイル使用メモリ 82,236 KB
実行使用メモリ 57,728 KB
最終ジャッジ日時 2024-11-18 21:35:06
合計ジャッジ時間 2,085 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 998244353


def my_factorial(a):
	ret = 1
	for i in range(1, a+1):
		ret *= i
		ret %= MOD

	return ret


def comb(a, b):
	ret = my_factorial(a)
	d = my_factorial(b) * my_factorial(a-b)
	d %= MOD

	ret = my_factorial(a) * pow(d, MOD-2, MOD)
	return ret % MOD


X, Y, Z, W = map(int, input().split())

if Z == 0:
	ans = comb(Y, Y-W) * X * my_factorial(X+Y-W-1)
else:
	ans = comb(X, X-Z) * Y * my_factorial(X+Y-Z-1)
print(ans % MOD)
0