結果
| 問題 | No.3549 SigMax Digits (Judge ver.) |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-05-22 23:57:15 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 519 ms / 3,000 ms |
| コード長 | 965 bytes |
| 記録 | |
| コンパイル時間 | 3,487 ms |
| コンパイル使用メモリ | 332,596 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-05-22 23:57:28 |
| 合計ジャッジ時間 | 5,457 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_1 |
| 純コード判定待ち |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 7 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int T;
cin >> T;
while(T--){
ll l, r;
cin >> l >> r;
auto f = [&](ll v){
string s = to_string(v);
array<array<ll,10>,2> dp{};
dp[1][0] = 1;
for(auto c : s){
array<array<ll,10>,2> ndp{};
for(int i = 0; i < 2; i++){
int r = i ? c - '0' : 9;
for(int j = 0; j < 10; j++){
for(int k = 0; k <= r; k++){
ndp[i & (k == r)][max(j, k)] += dp[i][j];
}
}
}
dp = ndp;
}
ll res = 0;
for(int i = 1; i < 10; i++) res += i * (dp[0][i] + dp[1][i]);
return res;
};
cout << f(r) - f(l - 1) << '\n';
}
}