結果
| 問題 |
No.3089 Base M Numbers, But Only 0~9
|
| コンテスト | |
| ユーザー |
umezo
|
| 提出日時 | 2025-04-04 23:02:19 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 970 bytes |
| コンパイル時間 | 4,244 ms |
| コンパイル使用メモリ | 278,140 KB |
| 実行使用メモリ | 9,856 KB |
| 最終ジャッジ日時 | 2025-04-04 23:02:30 |
| 合計ジャッジ時間 | 4,741 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 13 WA * 6 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
template <class T> using V=vector<T>;
template <class T> using VV=V<V<T>>;
const int MOD=998244353;
int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
ll m;
cin>>m;
string s;
cin>>s;
int n=s.size();
ll t=1;
reverse(ALL(s));
V<ll> S(n),C(n);
rep(i,n){
ll a=s[i]-'0';
if(a<=(m-1)%10){
C[i]=(m-1)/10+1;
}
else{
C[i]=(m-1)/10;
}
if(a!=0) S[i]=C[i]*(a+5*(C[i]-1)%MOD)%MOD;
else S[i]=C[i]*(0+5*(C[i]-1)%MOD)%MOD;
}
V<ll> L(n),R(n);
L[0]=C[0],R[n-1]=C[n-1];
for(int i=1;i<n;i++) L[i]=L[i-1]*C[i]%MOD;
for(int i=n-2;i>=0;i--) R[i]=R[i+1]*C[i]%MOD;
ll ans=0;
rep(i,n){
ll tmp=S[i]*t%MOD;
if(i) tmp=tmp*L[i-1]%MOD;
if(i<n-1) tmp=tmp*R[i+1]%MOD;
ans=(ans+tmp)%MOD;
t=t*m%MOD;
}
cout<<ans<<endl;
return 0;
}
umezo