結果

問題 No.3089 Base M Numbers, But Only 0~9
ユーザー Iroha_3856
提出日時 2025-04-04 21:31:51
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 529 bytes
コンパイル時間 761 ms
コンパイル使用メモリ 82,480 KB
実行使用メモリ 122,536 KB
最終ジャッジ日時 2025-04-04 21:35:09
合計ジャッジ時間 3,889 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other TLE * 1 -- * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

M = int(input())
N = input()
now, mod = 1, 998244353
ans = 0

mul = 1

F = []

for i in range(len(N)):
	t = ord(N[len(N)-i-1])-ord('0')
	#t, t+10, ... < M
	x = ((M-1)-t)//10
	cnt = x+1
	first = t
	last = first + (cnt-1) * 10
	# print(first, last, cnt)
	s = (first + last) * cnt // 2
	F.append((s*now, cnt))
	now = now * M % mod

S = []
nnow = 1
for i in range(len(N)):
	S.append(nnow)
	nnow *= F[i][1]
	nnow %= mod

nnow = 1
for i in reversed(range(len(N))):
	ans += F[i][0] * nnow * S[i]
	ans %= mod
	nnow *= F[i][1]

print(ans)
0