結果

問題 No.897 compαctree
ユーザー wait_sushiwait_sushi
提出日時 2019-10-07 05:38:08
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 732 bytes
コンパイル時間 1,357 ms
コンパイル使用メモリ 158,820 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-20 12:57:22
合計ジャッジ時間 1,812 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> P;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF = 99999999999999;
const ll MOD = 1000000007;
ll a, b, c, d, e, f, p, q, t, k, m, n, ans = 0;
vl N, K;

void input(void) {
	cin >> q;
}

void solve(void){
	while (q--) {
		cin >> n >> k;
		if (k == 1) {
			cout << n - 1 << endl;
		}
		else {
			a = 1;
			ans = -1;
			while (n > 0) {
				n -= a;
				a = a * k;
				ans++;
			}
			cout << ans << endl;
		}
	}
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	input();
	solve();
}
0