結果

問題 No.3099 Parentheses Decomposition
ユーザー D M
提出日時 2025-04-18 12:13:14
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 687 bytes
コンパイル時間 709 ms
コンパイル使用メモリ 81,888 KB
実行使用メモリ 78,088 KB
最終ジャッジ日時 2025-04-18 12:13:18
合計ジャッジ時間 4,090 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 19 RE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

n=int(input())
n//=2
s=input()
mod=998244353
class cMod :
    def __init__(self, mod, size):
        fact = [1 for _ in range(size)]
        ifact = [1 for _ in range(size)]

        for i in range(1, size) :
            fact[i] = fact[i-1] * i % mod

        ifact[size-1] = pow(fact[size-1], mod-2, mod)

        for i in range(size-2, -1, -1):
            ifact[i] = ifact[i+1] * (i+1) % mod
        self.fact = fact
        self.ifact = ifact


    def nCk(self, n: int, k: int) -> int:
        if n < k or k < 0 : return 0
        return self.fact[n] * self.ifact[k] % mod * self.ifact[n-k]%mod
m=cMod(mod,5*10**5)
if s[1]=="(":
    print(m.nCk(2*n,n))
else:
    print(pow(2,n,mod))
0