結果

問題 No.897 compαctree
ユーザー hitonanode
提出日時 2019-10-22 21:17:33
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 480 bytes
コンパイル時間 1,540 ms
コンパイル使用メモリ 166,692 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-04 19:15:35
合計ジャッジ時間 1,944 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define REP(i, n) FOR(i,0,n)

int main()
{
    lint Q, N, K;
    cin >> Q;
    REP(_, Q)
    {
        cin >> N >> K;
        lint ret = 0, a = 1;
        if (K == 1)
        {
            ret = N - 1;
        }
        else
        {
            while (a < N) ret++, a = a * K + 1;
        }
        cout << ret << endl;
    }
}
0