結果

問題 No.897 compαctree
コンテスト
ユーザー Today03
提出日時 2026-10-14 16:11:57
言語 C++23
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 781 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,278 ms
コンパイル使用メモリ 184,736 KB
実行使用メモリ 9,872 KB
最終ジャッジ日時 2026-10-14 16:12:01
合計ジャッジ時間 2,991 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 14 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <numeric>
using namespace std;
using ii = long long;
using ll = long long;
#define rep(i, N) for(ii i = 0; i < (N); i++)
#define all(v) (v).begin(), (v).end()
void chmin(auto& a, auto b) { a = (a < b ? a : b); }
void chmax(auto& a, auto b) { a = (a > b ? a : b); }
const ii INF = 1e9 + 10;
const ll INFL = 4e18;

void run() {
    ii N, K;
    cin >> N >> K;

    if(K == 1) {
        cout << N - 1 << '\n';
        return;
    }

    ii ans = 0, cur = 1;
    while(cur < N) {
        cur *= K;
        ans++;
    }

    cout << ans << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int T = 1;
    cin >> T;
    while(T--) run();
}
0