結果
| 問題 | 
                            No.897 compαctree
                             | 
                    
| コンテスト | |
| ユーザー | 
                             nasadigital
                         | 
                    
| 提出日時 | 2019-10-04 21:38:31 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 524 bytes | 
| コンパイル時間 | 1,535 ms | 
| コンパイル使用メモリ | 165,536 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2024-10-03 07:21:07 | 
| 合計ジャッジ時間 | 1,962 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 10 WA * 3 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int q, n, k;
    cin >> q;
    for (int ctr1 = 0; ctr1 < q; ++ctr1) {
        cin >> n >> k;
        if (k == 1) {
            cout << n - 1 << " ";
            continue;
        }
        ll cur = 1, rez = 0;
        while (n > cur) {
            n -= cur;
            cur *= k;
            ++rez;
        }
        cout << rez << "\n";
    }
    return 0;
}
            
            
            
        
            
nasadigital