結果

問題 No.2409 Strange Werewolves
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2023-08-11 22:32:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 96 ms / 2,000 ms
コード長 595 bytes
コンパイル時間 187 ms
コンパイル使用メモリ 82,764 KB
実行使用メモリ 89,728 KB
最終ジャッジ日時 2024-04-29 13:35:22
合計ジャッジ時間 1,958 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
51,456 KB
testcase_01 AC 45 ms
61,440 KB
testcase_02 AC 34 ms
51,968 KB
testcase_03 AC 96 ms
84,736 KB
testcase_04 AC 52 ms
67,200 KB
testcase_05 AC 49 ms
63,232 KB
testcase_06 AC 85 ms
84,480 KB
testcase_07 AC 87 ms
89,728 KB
testcase_08 AC 71 ms
80,384 KB
testcase_09 AC 77 ms
89,600 KB
testcase_10 AC 54 ms
68,736 KB
testcase_11 AC 48 ms
64,000 KB
testcase_12 AC 56 ms
70,400 KB
testcase_13 AC 58 ms
72,192 KB
testcase_14 AC 68 ms
81,152 KB
testcase_15 AC 90 ms
85,120 KB
testcase_16 AC 60 ms
75,520 KB
testcase_17 AC 50 ms
64,128 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

x,y,z,w = map(int,input().split())
mod = 998244353

### for bigger prime 
N = x+y+5
fact = [1]*N
finv = [1]*N
 
for i in range(2,N):
    fact[i] = (fact[i-1]*i)%mod
finv[-1] = pow(fact[-1],mod-2,mod)
for i in range(1,N)[::-1]:
    finv[i-1] = (finv[i]*i)%mod

def nCr(n,r):
    if r > n:
        return 0
    else: 
        return fact[n]*finv[r]%mod*finv[n-r]%mod


if z:
    x,y = y,x
    z,w = w,z

## z = 0

ans = nCr(y,y-w) * nCr(x+y-z-w,x) * fact[y-w] * fact[x] % mod

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