結果

問題 No.2409 Strange Werewolves
ユーザー hato336hato336
提出日時 2023-08-11 21:40:27
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 922 bytes
コンパイル時間 156 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 71,168 KB
最終ジャッジ日時 2024-04-29 12:31:33
合計ジャッジ時間 6,856 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 306 ms
62,720 KB
testcase_01 AC 305 ms
62,592 KB
testcase_02 AC 305 ms
62,848 KB
testcase_03 RE -
testcase_04 AC 306 ms
62,336 KB
testcase_05 AC 305 ms
62,720 KB
testcase_06 RE -
testcase_07 RE -
testcase_08 AC 306 ms
62,592 KB
testcase_09 AC 305 ms
62,720 KB
testcase_10 AC 306 ms
62,720 KB
testcase_11 AC 305 ms
62,336 KB
testcase_12 AC 308 ms
62,464 KB
testcase_13 AC 307 ms
63,104 KB
testcase_14 RE -
testcase_15 RE -
testcase_16 AC 304 ms
62,336 KB
testcase_17 AC 305 ms
62,592 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

human = x-z
wolf = y-w
mod = 998244353
ans = 1
class comb():
    def __init__(self,n,mod):
        self.fact = [0] * (n+1)
        self.fact_inv = [0] * (n+1)
        self.mod = mod

        self.fact[1] = 1
        self.fact_inv[1] = pow(1,mod-2,mod)
        self.fact[0] = 1
        self.fact_inv[0] = 1

        for i in range(2,n+1):
            self.fact[i] = (self.fact[i-1] * i) % mod
            self.fact_inv[i] = (self.fact_inv[i-1] * pow(i,mod-2,mod)) % mod
        
    def ncr(self,n,r):
        return (self.fact[n] * self.fact_inv[r] * self.fact_inv[n-r]) % self.mod
c = comb(3*10**5+10,mod)
if w == 0:
    human,wolf = wolf,human
    z,w=w,z
    x,y=y,x
if z == 0:
    human -= 1
    ans *= c.ncr(human+wolf,min(human,wolf))
    ans *= c.ncr(x,human+1)
    ans *= c.ncr(y,wolf)
    ans *=c.fact[human+1]
    ans %= mod
    ans *= c.fact[wolf]
    ans %= mod
print(ans)

0