結果

問題 No.897 compαctree
ユーザー yuly3yuly3
提出日時 2020-05-11 18:23:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 79 ms / 2,000 ms
コード長 474 bytes
コンパイル時間 293 ms
コンパイル使用メモリ 87,072 KB
実行使用メモリ 71,564 KB
最終ジャッジ日時 2023-09-25 21:06:37
合計ジャッジ時間 2,859 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,516 KB
testcase_01 AC 77 ms
71,372 KB
testcase_02 AC 76 ms
71,356 KB
testcase_03 AC 76 ms
71,276 KB
testcase_04 AC 77 ms
71,384 KB
testcase_05 AC 78 ms
71,244 KB
testcase_06 AC 78 ms
71,248 KB
testcase_07 AC 79 ms
71,248 KB
testcase_08 AC 77 ms
71,360 KB
testcase_09 AC 77 ms
71,372 KB
testcase_10 AC 78 ms
71,284 KB
testcase_11 AC 75 ms
71,444 KB
testcase_12 AC 79 ms
71,564 KB
testcase_13 AC 75 ms
71,312 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    Q = int(rl())
    ans = []
    for _ in range(Q):
        N, K = map(int, rl().split())
        if K == 1:
            ans.append(N - 1)
            continue
        sm = 1
        tmp = 1
        depth = 0
        while sm < N:
            tmp *= K
            depth += 1
            sm += tmp
        ans.append(depth)
    print(*ans, sep='\n')


if __name__ == '__main__':
    solve()
0