結果

問題 No.897 compαctree
ユーザー fine
提出日時 2019-10-04 21:27:34
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 547 bytes
コンパイル時間 1,642 ms
コンパイル使用メモリ 166,216 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-10-03 07:11:31
合計ジャッジ時間 2,057 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 8 WA * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

ll solve(ll n, ll K) {
    if (K == 1) return n - 1;
    int ans = 0;
    ll hoge = K;
    while (true) {
        ll foo = (hoge - 1) / (K - 1);
        if (foo >= n) {
            break;
        }
        ans++;
        hoge *= K;
    }
    return ans;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        ll n, K;
        cin >> n >> K;
        cout << solve(n, K) << "\n";
    }
    return 0;
}
0