結果

問題 No.2865 Base 10 Subsets 2
コンテスト
ユーザー H3PO4
提出日時 2024-08-30 21:56:34
言語 Python3
(3.14.7 + numpy 2.5.2 + scipy 1.18.0 + ACL)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 93 ms / 2,000 ms
+ 758µs
コード長 464 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 300 ms
コンパイル使用メモリ 21,284 KB
実行使用メモリ 15,868 KB
最終ジャッジ日時 2026-08-25 09:35:02
合計ジャッジ時間 2,889 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

N, K = map(int, input().split())

# 31415 -> [3, 1, 4, 1, 5]
N_list = list(map(int, str(N)))

ct = 1
prod = []
final_digit = len(N_list)
for digit in range(len(N_list)):
    idx = len(N_list) - digit - 1
    if ct * (N_list[idx] + 1) >= K:
        final_digit = digit
        break
    ct *= N_list[idx] + 1
    prod.append(ct)

ans = 0
K -= 1
for i in range(final_digit - 1, -1, -1):
    x, K = divmod(K, prod[i])
    ans += x * 10 ** (i + 1)
ans += K
print(ans)
0