結果
| 問題 | No.897 compαctree |
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-03-20 21:10:47 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 54 ms / 2,000 ms |
| コード長 | 845 bytes |
| 記録 | |
| コンパイル時間 | 219 ms |
| コンパイル使用メモリ | 96,240 KB |
| 実行使用メモリ | 79,208 KB |
| 最終ジャッジ日時 | 2026-07-07 12:59:43 |
| 合計ジャッジ時間 | 2,197 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 13 |
ソースコード
import sys
def main():
input = sys.stdin.read().split()
Q = int(input[0])
idx = 1
for _ in range(Q):
N = int(input[idx])
K = int(input[idx + 1])
idx += 2
if K == 1:
print(N - 1)
continue
low = 0
high = 60
ans = 0
while low <= high:
mid = (low + high) // 2
total = 0
current = 1
possible = False
for _ in range(mid + 1):
total += current
if total >= N:
possible = True
break
current *= K
if possible:
ans = mid
high = mid - 1
else:
low = mid + 1
print(ans)
if __name__ == '__main__':
main()
lam6er