結果

問題 No.2416 vs Slime
ユーザー NakLon131NakLon131
提出日時 2023-08-12 15:15:40
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 39 ms / 2,000 ms
コード長 313 bytes
コンパイル時間 355 ms
コンパイル使用メモリ 82,460 KB
実行使用メモリ 55,900 KB
最終ジャッジ日時 2024-04-30 08:38:59
合計ジャッジ時間 3,069 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
54,460 KB
testcase_01 AC 39 ms
55,044 KB
testcase_02 AC 35 ms
55,056 KB
testcase_03 AC 38 ms
54,508 KB
testcase_04 AC 39 ms
54,328 KB
testcase_05 AC 39 ms
55,020 KB
testcase_06 AC 39 ms
55,644 KB
testcase_07 AC 36 ms
55,284 KB
testcase_08 AC 38 ms
54,564 KB
testcase_09 AC 35 ms
54,312 KB
testcase_10 AC 34 ms
55,900 KB
testcase_11 AC 37 ms
54,300 KB
testcase_12 AC 36 ms
54,652 KB
testcase_13 AC 37 ms
55,228 KB
testcase_14 AC 36 ms
55,064 KB
testcase_15 AC 36 ms
54,184 KB
testcase_16 AC 38 ms
54,444 KB
testcase_17 AC 36 ms
53,932 KB
testcase_18 AC 36 ms
54,580 KB
testcase_19 AC 37 ms
55,344 KB
testcase_20 AC 37 ms
54,144 KB
testcase_21 AC 36 ms
54,140 KB
testcase_22 AC 36 ms
54,116 KB
testcase_23 AC 35 ms
54,236 KB
testcase_24 AC 36 ms
54,476 KB
testcase_25 AC 36 ms
55,832 KB
testcase_26 AC 37 ms
54,112 KB
testcase_27 AC 36 ms
54,592 KB
testcase_28 AC 37 ms
54,500 KB
testcase_29 AC 36 ms
54,368 KB
testcase_30 AC 35 ms
55,616 KB
testcase_31 AC 36 ms
54,344 KB
testcase_32 AC 36 ms
54,724 KB
testcase_33 AC 36 ms
54,792 KB
testcase_34 AC 38 ms
54,508 KB
testcase_35 AC 37 ms
54,216 KB
testcase_36 AC 36 ms
54,588 KB
testcase_37 AC 35 ms
54,268 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq
from collections import defaultdict

n, a = map(int, input().split())

ans = 0
hp = []
heapq.heappush(hp, [-n, 1])	# 降順にするため負値

while(len(hp) > 0):
	val, cnt = heapq.heappop(hp)
	val *= -1
	ans += cnt

	n_val = val // a
	if n_val > 0: heapq.heappush(hp, [-n_val, cnt*2])

print(ans)
0