結果
| 問題 |
No.3089 Base M Numbers, But Only 0~9
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-04-04 22:50:58 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 784 bytes |
| コンパイル時間 | 7,434 ms |
| コンパイル使用メモリ | 331,876 KB |
| 実行使用メモリ | 6,144 KB |
| 最終ジャッジ日時 | 2025-04-04 22:51:16 |
| 合計ジャッジ時間 | 7,299 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge6 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 13 WA * 6 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;
using mint=modint998244353;
int main()
{
ll m;
cin>>m;
string s;
cin>>s;
int n=s.size();
mint ss=1;
int cnt=0;
for(int i=0;i<n;i++){
mint x=m/10;
if((s[i]-'0')<m%10)x++;
if(x.val()!=0)ss*=x;
else cnt++;
}
if(cnt>1){
cout<<0<<endl;
return 0;
}
mint ans=0;
mint t=1;
reverse(s.begin(),s.end());
for(int i=0;i<n;i++){
mint x=m/10;
if((s[i]-'0')<m%10)x++;
if(cnt==0)ans+=ss/x*((s[i]-'0')*x+5*x*(x-1))*t;
else if(cnt==1&&x.val()==0)ans+=ss*((s[i]-'0')*x+5*x*(x-1))*t;
t*=m;
}
cout<<ans.val()<<endl;
return 0;
}