結果

問題 No.2872 Depth of the Parentheses
ユーザー D M
提出日時 2025-02-10 16:31:26
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 48 ms / 2,000 ms
コード長 481 bytes
コンパイル時間 399 ms
コンパイル使用メモリ 82,236 KB
実行使用メモリ 369,612 KB
最終ジャッジ日時 2025-02-10 16:31:44
合計ジャッジ時間 17,918 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20 TLE * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(10 ** 8)
from functools import lru_cache
mod=998244353
x,k=map(int,input().split())
@lru_cache(maxsize=None)
def dfs(tmax,nowt,ind):
    if 2*k-ind==nowt:
        return tmax
    if ind==2*k:
        return 0
    stc=0
    if nowt>0:
        stc+=dfs(tmax,nowt-1,ind+1)
    stc+=dfs(max(tmax,nowt+1),nowt+1,ind+1)
    return stc%mod
t=dfs(0,0,0)
p=x*pow(100,-1,mod)%mod
pi=(100-x)*pow(100,-1,mod)%mod
ans=pow(p,k,mod)*pow(pi,k,mod)*t%mod
print(ans)
0