結果
問題 | No.897 compαctree |
ユーザー |
![]() |
提出日時 | 2025-03-20 21:10:47 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 36 ms / 2,000 ms |
コード長 | 845 bytes |
コンパイル時間 | 149 ms |
コンパイル使用メモリ | 82,496 KB |
実行使用メモリ | 53,292 KB |
最終ジャッジ日時 | 2025-03-20 21:10:49 |
合計ジャッジ時間 | 1,239 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 13 |
ソースコード
import sysdef main():input = sys.stdin.read().split()Q = int(input[0])idx = 1for _ in range(Q):N = int(input[idx])K = int(input[idx + 1])idx += 2if K == 1:print(N - 1)continuelow = 0high = 60ans = 0while low <= high:mid = (low + high) // 2total = 0current = 1possible = Falsefor _ in range(mid + 1):total += currentif total >= N:possible = Truebreakcurrent *= Kif possible:ans = midhigh = mid - 1else:low = mid + 1print(ans)if __name__ == '__main__':main()