結果

問題 No.2246 1333-like Number
ユーザー lam6er
提出日時 2025-04-15 23:14:17
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,058 ms / 2,000 ms
コード長 695 bytes
コンパイル時間 247 ms
コンパイル使用メモリ 82,336 KB
実行使用メモリ 76,096 KB
最終ジャッジ日時 2025-04-15 23:16:58
合計ジャッジ時間 15,570 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq

n = int(input())

# Generate all valid (a, b) pairs where a < b
pairs = []
for a in range(1, 10):
    for b in range(a + 1, 10):
        pairs.append((a, b))

# Initialize the heap with the initial elements (c=0)
heap = []
for a, b in pairs:
    heapq.heappush(heap, (2, a, b, 0))  # (length, a, b, c)

current_step = 0
result = None

while heap:
    length, a, b, c = heapq.heappop(heap)
    current_step += 1
    if current_step == n:
        # Construct the result string
        result = str(a) + str(b) + str(b) * c
        break
    # Push the next element in this (a, b) sequence
    new_length = length + 1
    heapq.heappush(heap, (new_length, a, b, c + 1))

print(result)
0