結果

問題 No.897 compαctree
ユーザー MisterMister
提出日時 2020-04-10 17:12:21
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 468 bytes
コンパイル時間 1,645 ms
コンパイル使用メモリ 68,184 KB
実行使用メモリ 4,376 KB
最終ジャッジ日時 2023-10-13 08:32:21
合計ジャッジ時間 1,781 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,372 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 1 ms
4,368 KB
testcase_12 AC 1 ms
4,368 KB
testcase_13 AC 2 ms
4,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>

void solve() {
    int n, k;
    std::cin >> n >> k;

    if (k == 1) {
        std::cout << n - 1 << std::endl;
        return;
    }

    int ch = 1, d = 0;
    while (true) {
        n -= ch;
        if (n <= 0) break;

        ch *= k;
        ++d;
    }

    std::cout << d << std::endl;
}

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

    int q;
    std::cin >> q;
    while (q--) solve();

    return 0;
}
0