結果
| 問題 |
No.3089 Base M Numbers, But Only 0~9
|
| コンテスト | |
| ユーザー |
sasa8uyauya
|
| 提出日時 | 2025-04-04 23:20:49 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 488 bytes |
| コンパイル時間 | 765 ms |
| コンパイル使用メモリ | 82,252 KB |
| 実行使用メモリ | 96,448 KB |
| 最終ジャッジ日時 | 2025-04-04 23:20:53 |
| 合計ジャッジ時間 | 3,872 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | RE * 5 |
| other | RE * 19 |
ソースコード
M=998244353
m=int(input())
n=list(map(int,input()))[::-1]
pl=[1]*(len(n)+1)
for i in range(len(n)):
d=n[i]
c=(m-1-d)//10+1
pl[i+1]=pl[i]*c%M
pr=[1]*(len(n)+1)
for i in range(len(n)):
d=n[~i]
c=(m-1-d)//10+1
pr[i+1]=pr[i]*c%M
a=0
for i in range(len(n)):
d=n[i]
c=(m-1-d)//10+1
if i==n-1 and d==0:
c-=1
a+=(((c+1)*c*pow(2,M-2,M))*10+d*c)*pl[i]*pr[len(n)-i-1]*pow(m,i,M)
else:
a+=(((c-1)*c*pow(2,M-2,M))*10+d*c)*pl[i]*pr[len(n)-i-1]*pow(m,i,M)
a%=M
print(a)
sasa8uyauya