結果

問題 No.3548 SigMax Digits (Construction ver.)
コンテスト
ユーザー umezo
提出日時 2026-05-25 01:13:32
言語 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  
実行時間 21 ms / 2,000 ms
コード長 970 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,932 ms
コンパイル使用メモリ 335,576 KB
実行使用メモリ 7,972 KB
最終ジャッジ日時 2026-05-25 01:13:39
合計ジャッジ時間 5,714 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_1
純コード判定待ち
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 7
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
template <class T> using V=vector<T>;
template <class T> using VV=V<V<T>>;
using u128=__int128_t;
using ll=long long;

const ll M=888888888888888888;
int f(ll x){
  ll ma=0;
  while(x){
    ma=max(ma,x%10);
    x/=10;
  }
  return ma;
}
 
int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  V<ll> L(100,-1),R(100,-1);
  for(int i=1;i<100;i++){
    for(int j=i;j<100;j++){
      int sum=0;
      for(int k=i;k<=j;k++) sum+=f(k);
      if(sum<100 && L[sum]==-1) L[sum]=i,R[sum]=j;
    }
  }
  
  int t;
  cin>>t;
  while(t--){
    ll n;
    cin>>n;
    if(n<100) cout<<L[n]<<" "<<R[n]<<'\n';
    else{
      ll q=n/9,r=n%9;
      if(r==0) cout<<M+1<<" "<<M+q<<'\n';
      else cout<<M-(8-r)<<" "<<M+q-(8-r)<<'\n';
    }
  }
    
  return 0;
}
0