結果

問題 No.3548 SigMax Digits (Construction ver.)
コンテスト
ユーザー Tehom
提出日時 2026-05-22 22:42:25
言語 C++17
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 1,179 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 4,236 ms
コンパイル使用メモリ 273,424 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-05-22 22:42:36
合計ジャッジ時間 4,192 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 1
other WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define ll long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define repl(i,a,b) for(ll i=(a);i<(b);i++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

template <typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;} return false;}
template <typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;} return false;}


void solve(){
  // set<int> st;
  // rep(i,0,20)rep(j,0,20){
  //   st.insert(8*i+9*j);
  // }
  // rep(i,0,200)if(!st.count(i)) cout << i << "\n";
  
  
  ll n; cin >> n;
  auto f=[](int x) -> int{
    int res=0;
    while(x){
      chmax(res,x%10);
      x/=10;
    }
    return res;
  };
  if(n<=55){
    rep(j,2,60)rep(i,1,j){
      ll sum=0;
      rep(k,i,j+1) sum+=f(k);
      if(sum == n){
        cout << i << " " << j << "\n";
        return;
      }
    }
  }

  ll b=n%8;
  ll a=(n-9*b)/8;
  ll mid=8;
  rep(i,0,17){
    mid*=10;
    mid+=8;
  }

  cout << mid-a+1 << " " << mid+b << "\n";
  

  return;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int T=1;
  cin >> T;
  while(T--) solve();
}
0