結果
| 問題 | 
                            No.897 compαctree
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2023-06-13 16:17:20 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 2 ms / 2,000 ms | 
| コード長 | 557 bytes | 
| コンパイル時間 | 1,586 ms | 
| コンパイル使用メモリ | 170,152 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-06-22 01:30:45 | 
| 合計ジャッジ時間 | 2,217 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 13 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
int main() {
  int Q; cin >> Q;
  vector<pair<int,int>> NK(Q);
  for(int i = 0; i < Q; i++) {
    int a,b; cin >>a >> b;
    NK[i] = {a,b};
  }
  for(int i = 0; i < Q; i++) {
    int x = NK[i].first;
    int y = NK[i].second;
    
    if(y == 1) {
      cout << x- 1 << endl;
      continue;
    }
    int ans = 0;
    if(x % y == 0) ans -= 1;
    while(true) {
      if(x == 0) break;
      x /= y;
      ans++;
    }
    
    cout <<ans << endl;
  }
}