結果

問題 No.897 compαctree
ユーザー ohana
提出日時 2023-10-30 15:17:15
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 40 ms / 2,000 ms
コード長 257 bytes
コンパイル時間 194 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 52,224 KB
最終ジャッジ日時 2024-09-25 17:16:10
合計ジャッジ時間 1,242 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

q = int(input())

for i in range(q):
    n, k = map(int, input().split())
    if k == 1:
        print(n - 1)
    else:
        cnt = 0
        n -= 1
        while n > 0:
            n -= k ** (cnt + 1)
            cnt += 1
        print(cnt)
0