結果
| 問題 | No.3549 SigMax Digits (Judge ver.) |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-05-22 22:38:02 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 976 ms / 3,000 ms |
| コード長 | 733 bytes |
| 記録 | |
| コンパイル時間 | 2,335 ms |
| コンパイル使用メモリ | 337,344 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-05-22 22:38:12 |
| 合計ジャッジ時間 | 6,974 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge3_0 |
| 純コード判定待ち |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 7 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
cin.tie(nullptr);
ios::sync_with_stdio(false);
int ttt;
cin>>ttt;
auto f=[](ll x)->ll{
if(x==0)return 0;
string s=to_string(x);
int n=s.size();
vector<ll> dp(20);
dp[0]=1;
for(int i=0;i<n;i++){
vector<ll> ndp(20);
for(int j=0;j<20;j++){
int x=j/10,y=j%10;
for(int d=0;d<10;d++){
if(d<s[i]-'0'){
ndp[10+max(y,d)]+=dp[j];
}else if(d==s[i]-'0'){
ndp[x*10+max(y,d)]+=dp[j];
}else{
if(x==1)ndp[10+max(y,d)]+=dp[j];
}
}
}
dp=ndp;
}
ll res=0;
for(int i=0;i<20;i++)res+=(i%10)*dp[i];
return res;
};
while(ttt--){
ll l,r;
cin>>l>>r;
cout<<f(r)-f(l-1)<<endl;
}
}