結果

問題 No.897 compαctree
ユーザー ttrttr
提出日時 2020-02-04 18:46:20
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 368 bytes
コンパイル時間 150 ms
コンパイル使用メモリ 11,920 KB
実行使用メモリ 22,184 KB
最終ジャッジ日時 2023-10-21 06:29:24
合計ジャッジ時間 3,612 ms
ジャッジサーバーID
(参考情報)
judge10 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
14,536 KB
testcase_01 TLE -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

Q = int(input())

def S(r, n):
    if r == 1:
        return n+1
    return (pow(r, n+1)-1)//(r-1)

for _ in range(Q):
    N,K = map(int, input().split())
    l = 0
    r = N+1
    while r-l > 1:
        m = (r+l)//2
        if S(K, m) < N:
            l = m
        else:
            r = m
    if S(K, l) >= N:
        ans = l
    else:
        ans = r
    print(ans)
0