結果

問題 No.2409 Strange Werewolves
ユーザー グミグミ
提出日時 2023-08-11 23:00:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 60 ms / 2,000 ms
コード長 455 bytes
コンパイル時間 298 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 57,472 KB
最終ジャッジ日時 2024-04-29 14:10:29
合計ジャッジ時間 2,108 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
51,584 KB
testcase_01 AC 46 ms
57,088 KB
testcase_02 AC 42 ms
51,584 KB
testcase_03 AC 58 ms
57,344 KB
testcase_04 AC 55 ms
57,344 KB
testcase_05 AC 51 ms
56,960 KB
testcase_06 AC 60 ms
56,960 KB
testcase_07 AC 55 ms
57,472 KB
testcase_08 AC 52 ms
57,088 KB
testcase_09 AC 52 ms
57,216 KB
testcase_10 AC 50 ms
57,344 KB
testcase_11 AC 47 ms
57,216 KB
testcase_12 AC 50 ms
57,088 KB
testcase_13 AC 52 ms
57,344 KB
testcase_14 AC 53 ms
57,472 KB
testcase_15 AC 53 ms
57,088 KB
testcase_16 AC 51 ms
56,832 KB
testcase_17 AC 46 ms
56,960 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

modulus = 998244353

def main():
	x,y,z,w=map(int,input().split())	
	n = x-z+y-w
	f = fact(n-1)
	b1 = bin(x,x-z-1) if z == 0 else bin(x,x-z)
	b2 = bin(y,y-w-1) if w == 0 else bin(y,y-w)
	ans = (f*b1*b2) % modulus
	print(ans)

def fact(n):
	p = 1
	for k in range(1,n+1):
		p *= k
		p %= modulus
	return p

def bin(n,k):
	a = fact(n)
	b = fact(n-k)
	c = fact(k)
	bc = pow(b*c,-1,modulus)
	ans = a*bc % modulus
	return ans

if __name__ == "__main__":
	main()
0