結果

問題 No.2865 Base 10 Subsets 2
ユーザー VvyLwVvyLw
提出日時 2024-08-30 23:58:19
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 903 bytes
コンパイル時間 1,776 ms
コンパイル使用メモリ 130,644 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-08-30 23:58:21
合計ジャッジ時間 2,603 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize("O2")
#ifdef local
#include <C++/core/io/debug_print.hpp>
#else
#define dump(...) void(0);
#endif

#include <iostream>
#include <valarray>
namespace man {

}
int main() {
    std::cin.tie(nullptr) -> sync_with_stdio(false);
    int64_t n, k;
    std::cin >> n >> k;
    const auto sol = [&k](const int64_t n) -> std::string {
        std::string s;
        if(--k == 0) {
            return "0";
        }
        std::valarray<int64_t> v(1, 20);
        int id = 0;
        for(int64_t i = n; i > 0; ++id, i /= 10) {
            v[id + 1] = v[id] * (i % 10 + 1);
        }
        bool c = false;
        dump(v);
        while(id >= 0) {
            const auto x = k / v[id];
            if(x > 0 || c) {
                s += std::to_string(x);
                c = true;
            }
            k %= v[id--];
        }
        return s;
    };
    std::cout << sol(n) << '\n';
}
0