結果

問題 No.897 compαctree
ユーザー ぷら
提出日時 2022-03-24 16:27:03
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 40 ms / 2,000 ms
コード長 443 bytes
コンパイル時間 1,859 ms
コンパイル使用メモリ 192,724 KB
最終ジャッジ日時 2025-01-28 11:15:01
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
    int Q;
    cin >> Q;
    while (Q--) {
        int N,K;
        cin >> N >> K;
        if(K == 1) {
            cout << N-K << endl;
        }
        else {
            long long ans = 0,sum = 1,tmp = 1;
            while (sum < N) {
                sum += tmp*K;
                ans++;
                tmp *= K;
            }
            cout << ans << endl;
        }
    }
}
0