結果
| 問題 |
No.2060 AND Sequence
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-08-08 15:09:43 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
RE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 827 bytes |
| コンパイル時間 | 325 ms |
| コンパイル使用メモリ | 81,920 KB |
| 実行使用メモリ | 67,200 KB |
| 最終ジャッジ日時 | 2024-09-19 02:14:23 |
| 合計ジャッジ時間 | 3,761 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 42 RE * 1 |
ソースコード
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)