結果

問題 No.2865 Base 10 Subsets 2
コンテスト
ユーザー tnakao0123
提出日時 2024-09-03 17:04:14
言語 C++17
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 16 ms / 2,000 ms
コード長 779 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 149 ms
コンパイル使用メモリ 53,616 KB
実行使用メモリ 16,128 KB
最終ジャッジ日時 2026-07-05 14:17:33
合計ジャッジ時間 1,261 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

/* -*- coding: utf-8 -*-
 *
 * 2865.cc:  No.2865 Base 10 Subsets 2 - yukicoder
 */

#include<cstdio>
#include<algorithm>

using namespace std;

/* constant */

const int MAX_M = 20;

/* typedef */

using ll = long long;

/* global variables */

int as[MAX_M], bs[MAX_M];
ll ts[MAX_M];

/* subroutines */

/* main */

int main() {
  ll n, k;
  scanf("%lld%lld", &n, &k);
  k--;

  int m = 0;
  while (n > 0) as[m++] = n % 10, n /= 10;
  
  ts[0] = 1;
  for (int i = 1; i < m; i++) ts[i] = ts[i - 1] * (as[i - 1] + 1);

  for (int i = m - 1; i >= 0; i--) {
    bs[i] = k / ts[i];
    k -= ts[i] * bs[i];
  }

  while (m > 0 && bs[m - 1] == 0) m--;

  if (m == 0) puts("0");
  else {
    for (int i = m - 1; i >= 0; i--) printf("%d", bs[i]);
    putchar('\n');
  }
  
  return 0;
}
0