結果

問題 No.2409 Strange Werewolves
ユーザー 👑 timitimi
提出日時 2023-08-12 12:01:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 308 ms / 2,000 ms
コード長 452 bytes
コンパイル時間 169 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 251,984 KB
最終ジャッジ日時 2024-04-30 01:59:02
合計ジャッジ時間 6,689 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 300 ms
251,632 KB
testcase_01 AC 301 ms
251,888 KB
testcase_02 AC 305 ms
251,504 KB
testcase_03 AC 303 ms
251,756 KB
testcase_04 AC 302 ms
251,628 KB
testcase_05 AC 306 ms
251,984 KB
testcase_06 AC 306 ms
251,508 KB
testcase_07 AC 298 ms
251,632 KB
testcase_08 AC 300 ms
251,756 KB
testcase_09 AC 299 ms
251,376 KB
testcase_10 AC 302 ms
251,504 KB
testcase_11 AC 298 ms
251,640 KB
testcase_12 AC 303 ms
251,508 KB
testcase_13 AC 303 ms
251,504 KB
testcase_14 AC 308 ms
251,500 KB
testcase_15 AC 308 ms
251,760 KB
testcase_16 AC 302 ms
251,884 KB
testcase_17 AC 303 ms
251,632 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

x,y,z,w=map(int, input().split())
mod=998244353;n=10**6+100
inv_t=[0]+[1]
for i in range(2,n):
  inv_t+=[inv_t[mod%i]*(mod-int(mod/i))%mod]

kai=[1,1]
rev_kai=[1,inv_t[1]]
for i in range(2,n):
  kai.append(kai[-1]*i%mod)
  rev_kai.append(rev_kai[-1]*inv_t[i]%mod)

def cmb(n,r):
  return kai[n]*rev_kai[r]*rev_kai[n-r]%mod

if z==0:
  ans=x*cmb(y,w)
  z+=1
else:
  ans=y*cmb(x,z)
  w+=1

c=x+y-z-w
for i in range(1,c+1):
  ans*=i
  ans%=mod 
print(ans)
0