結果

問題 No.2060 AND Sequence
ユーザー taiga0629kyoprotaiga0629kyopro
提出日時 2022-09-24 09:12:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 44 ms / 2,000 ms
コード長 256 bytes
コンパイル時間 527 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 52,224 KB
最終ジャッジ日時 2024-12-22 05:53:19
合計ジャッジ時間 3,660 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #


n,m=map(int,input().split())
mod=998244353

memo=dict()
def dp(m):
    if m==0:return 1
    if m in memo:return memo[m]
    res=0
    for b in range(2):
        res+=dp((m-b)//2)*pow(n,b,mod)
        res%=mod
    memo[m]=res
    return res
print(dp(m))

0