結果

問題 No.897 compαctree
ユーザー tktk_snsn
提出日時 2020-06-05 19:04:30
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 30 ms / 2,000 ms
コード長 333 bytes
コンパイル時間 141 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-12-16 06:50:50
合計ジャッジ時間 1,082 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)
Q = int(input())
ans = [-1] * Q
for i in range(Q):
    n, k = map(int, input().split())
    if k == 1:
        ans[i] = n - 1
        continue
    cnt = 0
    while n > 1:
        n = (n + k - 2) // k
        cnt += 1
    ans[i] = cnt

print(*ans, sep="\n")
0