結果

問題 No.897 compαctree
ユーザー pyranine
提出日時 2020-12-21 11:37:30
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 451 bytes
コンパイル時間 2,102 ms
コンパイル使用メモリ 167,188 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-21 12:49:08
合計ジャッジ時間 2,886 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
  int query;
  cin >> query;
  for (int i = 0; i < query; i++) {
    int n, k;
    cin >> n >> k;
    if (k == 1) {
      cout << n - 1 << endl;
      continue;
    }
    else {
      int64_t now = 1, sum = 1;
      int ans = 0;
      while (true) {
        now *= k;
        sum += now;
        ans ++;
        if (sum >= n) break;
      }
      cout << ans << '\n';
    }
  }
  return 0;
}
0