結果

問題 No.3548 SigMax Digits (Construction ver.)
コンテスト
ユーザー tau1235
提出日時 2026-05-22 22:44:20
言語 C++23
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 139 ms / 2,000 ms
コード長 1,058 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,881 ms
コンパイル使用メモリ 334,384 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-05-22 22:44:39
合計ジャッジ時間 12,298 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_1
純コード判定待ち
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 7
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include<bits/stdc++.h>
using namespace std;

using ll=long long;
vector<pair<ll,ll>> vp={
{-1,-1},
{1,2},
{2,3},
{1,3},
{4,5},
{2,4},
{1,4},
{3,5},
{8,9},
{2,5},
{1,5},
{5,7},
{3,6},
{6,8},
{2,6},
{1,6},
{9,14},
{8,10},
{3,7},
{8,12},
{2,7},
{1,7},
{4,8},
{18,23},
{7,10},
{3,8},
{5,9},
{2,8},
{1,8},
{10,18},
{4,9},
{6,11},
{6,12},
{3,9},
{6,13},
{2,9},
{1,9},
{5,12},
{9,18},
{4,10},
{4,11},
{4,12},
{3,10},
{3,11},
{2,10},
{1,10},
{1,11},
{1,12},
{2,13},
{1,13},
{4,15},
{2,14},
{1,14},
{3,15},
{8,19},
{2,15},
{1,15},
{5,17},
{3,16},
{6,18},
{2,16},
{1,16},
{12,26},
{8,20},
{3,17},
{8,21},
{2,17},
{1,17},
{4,18},
{8,23}
};

void solve(){
  ll n;
  cin>>n;
  auto f=[&](ll x){
    ll ret=0;
    while (x){
      ret=max(ret,x%10);
      x/=10;
    }
    return ret;
  };
  if (n<64){
    auto [l,r]=vp[n];
    r--;
    cout<<l<<" "<<r<<endl;
    return;
  }
  ll rem=n%9;
  ll l=800000000000000000,r=l-1;
  for (int t=0;t<(9-rem)%9;t++) n-=f(++r);
  ll k=n/9;
  l-=k;
  cout<<l<<" "<<r<<endl;
}

int main(){
  int t;
  cin>>t;
  while (t--) solve();
}
0