結果
問題 |
No.2246 1333-like Number
|
ユーザー |
![]() |
提出日時 | 2025-04-16 16:04:02 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 979 ms / 2,000 ms |
コード長 | 639 bytes |
コンパイル時間 | 332 ms |
コンパイル使用メモリ | 82,376 KB |
実行使用メモリ | 76,112 KB |
最終ジャッジ日時 | 2025-04-16 16:10:35 |
合計ジャッジ時間 | 14,347 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 |
ソースコード
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 length of 2 for each pair heap = [] for a, b in pairs: heapq.heappush(heap, (2, a, b)) # Process the first (n-1) elements for _ in range(n - 1): length, a, b = heapq.heappop(heap) heapq.heappush(heap, (length + 1, a, b)) # The nth element is now the smallest in the heap length, a, b = heapq.heappop(heap) # Generate the resulting number as a string result = str(a) + str(b) + (length - 2) * str(b) print(result)