結果
問題 |
No.3089 Base M Numbers, But Only 0~9
|
ユーザー |
![]() |
提出日時 | 2025-04-04 23:17:58 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 417 bytes |
コンパイル時間 | 339 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 94,976 KB |
最終ジャッジ日時 | 2025-04-04 23:18:06 |
合計ジャッジ時間 | 7,616 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 13 WA * 6 |
ソースコード
M=998244353 m=int(input()) n=list(map(int,input()))[::-1] while len(n)-1>0 and n[-1]==0: n.pop() 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 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)