結果

問題 No.2060 AND Sequence
ユーザー chineristACchineristAC
提出日時 2022-08-08 15:09:43
言語 PyPy3
(7.3.13)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 827 bytes
コンパイル時間 354 ms
コンパイル使用メモリ 81,624 KB
実行使用メモリ 68,340 KB
最終ジャッジ日時 2023-10-19 05:55:01
合計ジャッジ時間 5,257 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
56,092 KB
testcase_01 AC 48 ms
56,092 KB
testcase_02 AC 54 ms
62,016 KB
testcase_03 AC 52 ms
56,092 KB
testcase_04 AC 48 ms
56,092 KB
testcase_05 AC 47 ms
56,092 KB
testcase_06 AC 48 ms
56,092 KB
testcase_07 AC 48 ms
56,092 KB
testcase_08 AC 49 ms
56,092 KB
testcase_09 AC 50 ms
56,092 KB
testcase_10 AC 48 ms
56,092 KB
testcase_11 AC 48 ms
56,092 KB
testcase_12 AC 48 ms
56,092 KB
testcase_13 AC 47 ms
56,092 KB
testcase_14 AC 54 ms
62,016 KB
testcase_15 AC 55 ms
62,016 KB
testcase_16 AC 56 ms
62,016 KB
testcase_17 AC 54 ms
62,016 KB
testcase_18 AC 54 ms
62,016 KB
testcase_19 AC 55 ms
64,064 KB
testcase_20 AC 53 ms
62,016 KB
testcase_21 AC 53 ms
62,016 KB
testcase_22 AC 54 ms
64,064 KB
testcase_23 AC 52 ms
62,016 KB
testcase_24 AC 54 ms
64,064 KB
testcase_25 AC 53 ms
62,016 KB
testcase_26 AC 53 ms
62,016 KB
testcase_27 AC 53 ms
64,064 KB
testcase_28 AC 54 ms
62,016 KB
testcase_29 AC 54 ms
62,016 KB
testcase_30 AC 55 ms
64,064 KB
testcase_31 AC 54 ms
62,016 KB
testcase_32 AC 54 ms
64,064 KB
testcase_33 AC 53 ms
62,016 KB
testcase_34 AC 53 ms
62,016 KB
testcase_35 AC 53 ms
62,016 KB
testcase_36 AC 54 ms
64,064 KB
testcase_37 AC 54 ms
64,064 KB
testcase_38 AC 53 ms
62,016 KB
testcase_39 AC 53 ms
62,016 KB
testcase_40 AC 53 ms
62,016 KB
testcase_41 AC 53 ms
62,016 KB
testcase_42 AC 54 ms
62,016 KB
testcase_43 AC 54 ms
62,016 KB
testcase_44 RE -
testcase_45 AC 55 ms
64,084 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys,random,bisect
from collections import deque,defaultdict,Counter
from heapq import heapify,heappop,heappush
from itertools import cycle, permutations
from math import log,gcd

input = lambda :sys.stdin.readline().rstrip()
mi = lambda :map(int,input().split())
li = lambda :list(mi())

mod = 998244353

N,M = mi()

memo = {0:[1],1:[1,1]}
def calc(M):
    if M in memo:
        return memo[M]
    if M < 0:
        return [0]
    
    res = [0] * 30
    A = calc((M-1)//2)
    for i in range(len(A)):
        if A[i]:
            res[i+1] += A[i]
            res[i+1] %= mod
    B = calc(M//2)
    for i in range(len(B)):
        res[i] += B[i]
        res[i] %= mod
    
    memo[M] = res
    return res

cnt = calc(M)
res = 0
for k in range(len(cnt)):
    res += pow(N,k,mod) * cnt[k] % mod
    res %= mod

print(res)
0