結果

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9 + 10;
const ll INFL = 4e18;

int main() {
    string S;
    cin >> S;
    ll K;
    cin >> K;
    int N = S.size();
    K--;

    string ans = "";
    for (int i = 0; i < N; i++) {
        ll cnt = 1;
        for (int j = i + 1; j < N; j++) cnt *= S[j] - '0' + 1;

        ans += char('0' + K / cnt);
        K %= cnt;
    }

    while (ans.size() > 1 && ans.front() == '0') {
        ans.erase(ans.begin());
    }

    cout << ans << endl;
}
0