結果

問題 No.2060 AND Sequence
ユーザー shotoyooshotoyoo
提出日時 2022-08-26 22:03:55
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 86 ms / 2,000 ms
コード長 894 bytes
コンパイル時間 290 ms
コンパイル使用メモリ 87,236 KB
実行使用メモリ 72,556 KB
最終ジャッジ日時 2023-08-04 01:35:08
合計ジャッジ時間 5,836 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
72,380 KB
testcase_01 AC 84 ms
72,256 KB
testcase_02 AC 84 ms
72,128 KB
testcase_03 AC 84 ms
72,492 KB
testcase_04 AC 82 ms
72,236 KB
testcase_05 AC 84 ms
72,128 KB
testcase_06 AC 82 ms
72,260 KB
testcase_07 AC 82 ms
72,252 KB
testcase_08 AC 84 ms
72,556 KB
testcase_09 AC 83 ms
72,348 KB
testcase_10 AC 82 ms
71,992 KB
testcase_11 AC 82 ms
72,140 KB
testcase_12 AC 83 ms
71,956 KB
testcase_13 AC 83 ms
71,988 KB
testcase_14 AC 84 ms
72,256 KB
testcase_15 AC 85 ms
72,524 KB
testcase_16 AC 85 ms
72,252 KB
testcase_17 AC 86 ms
72,308 KB
testcase_18 AC 83 ms
72,124 KB
testcase_19 AC 83 ms
71,944 KB
testcase_20 AC 83 ms
72,528 KB
testcase_21 AC 83 ms
72,252 KB
testcase_22 AC 82 ms
72,140 KB
testcase_23 AC 84 ms
72,256 KB
testcase_24 AC 83 ms
71,980 KB
testcase_25 AC 86 ms
72,240 KB
testcase_26 AC 84 ms
71,948 KB
testcase_27 AC 84 ms
72,072 KB
testcase_28 AC 84 ms
72,508 KB
testcase_29 AC 84 ms
72,252 KB
testcase_30 AC 84 ms
72,304 KB
testcase_31 AC 83 ms
72,244 KB
testcase_32 AC 84 ms
72,384 KB
testcase_33 AC 84 ms
72,124 KB
testcase_34 AC 84 ms
72,256 KB
testcase_35 AC 85 ms
72,140 KB
testcase_36 AC 85 ms
72,056 KB
testcase_37 AC 81 ms
72,160 KB
testcase_38 AC 83 ms
72,388 KB
testcase_39 AC 82 ms
72,072 KB
testcase_40 AC 83 ms
72,128 KB
testcase_41 AC 83 ms
72,508 KB
testcase_42 AC 82 ms
72,136 KB
testcase_43 AC 82 ms
72,500 KB
testcase_44 AC 85 ms
72,152 KB
testcase_45 AC 85 ms
72,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys, random
input = lambda : sys.stdin.readline().rstrip()


write = lambda x: sys.stdout.write(x+"\n"); writef = lambda x: print("{:.12f}".format(x))
debug = lambda x: sys.stderr.write(x+"\n")
YES="Yes"; NO="No"; pans = lambda v: print(YES if v else NO); INF=10**18
LI = lambda : list(map(int, input().split())); II=lambda : int(input())
def debug(_l_):
    for s in _l_.split():
        print(f"{s}={eval(s)}", end=" ")
    print()
def dlist(*l, fill=0):
    if len(l)==1:
        return [fill]*l[0]
    ll = l[1:]
    return [dlist(*ll, fill=fill) for _ in range(l[0])]

n,m = list(map(int, input().split()))
M = 998244353
dp0 = 1
dp1 = 0
val = n
for i in range(31)[::-1]:
    v = m>>i&1
    if v:
        ndp0 = val * dp0 % M
        ndp1 = val * dp1 % M + dp1 + dp0
    else:
        ndp0 = dp0
        ndp1 = val * dp1 % M + dp1
    dp0 = ndp0%M
    dp1 = ndp1%M
print((dp0+dp1)%M)
0