結果

問題 No.897 compαctree
ユーザー GrayCoder
提出日時 2019-10-04 22:44:43
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 28 ms / 2,000 ms
コード長 425 bytes
コンパイル時間 96 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-10-03 08:14:45
合計ジャッジ時間 997 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    Q = int(input())
    NK = [tuple(map(int, input().split())) for _ in [0] * Q]

    for n, k in NK:
        if k == 1:
            ans = n - 1
        else:
            x = 0
            for i in range(31):
                x += k ** i
                if x >= n:
                    ans = i
                    break
        print(ans)


main()
0