結果

問題 No.3625 Find Superfibonacci Number
コンテスト
ユーザー t98slider
提出日時 2026-08-14 21:59:11
言語 C++23
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 1,152 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,036 ms
コンパイル使用メモリ 337,332 KB
実行使用メモリ 9,312 KB
最終ジャッジ日時 2026-08-14 21:59:15
合計ジャッジ時間 3,486 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 12 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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

vector<int> top4 = {
    1908, // 18
    2908, // 19
    3908, // 20
    4908, // 21
    5908, // 22
    6908, // 23
    7908, // 24
    8908, // 25
    9089  // 26
};

vector<int> experiment(int r){
    vector<int> D(101, 1 << 30);
    for(int i = 100; i <= r; i++){
        auto s = to_string(i);
        bool flg = false;
        for(int j = 0; j + 2 < s.size(); j++){
            if(s[j] - '0' > (int)(s[j + 1] - '0') + (int)(s[j + 2] - '0')){
                flg = true;
                break;
            }
        }
        if(flg){
            int dig = 0;
            for(auto d : s) dig += d - '0';
            D[dig] = min(D[dig], i);
        }
    }
    return D;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    auto D = experiment(1000000);
    int T;
    cin >> T;
    while(T--){
        int K;
        cin >> K;
        if(K <= 45){
            cout << D[K] << '\n';
            continue;
        }
        int cnt = 0;
        while(K > 26){
            K -= 9;
            cnt++;
        }
        cout << to_string(top4[K - 18]) << string(cnt, '9') << "\n";
    }
}
0