結果
| 問題 |
No.897 compαctree
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-03-20 21:10:47 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 36 ms / 2,000 ms |
| コード長 | 845 bytes |
| コンパイル時間 | 149 ms |
| コンパイル使用メモリ | 82,496 KB |
| 実行使用メモリ | 53,292 KB |
| 最終ジャッジ日時 | 2025-03-20 21:10:49 |
| 合計ジャッジ時間 | 1,239 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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