結果

問題 No.897 compαctree
ユーザー furafura
提出日時 2020-04-13 13:50:22
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 319 bytes
コンパイル時間 2,212 ms
コンパイル使用メモリ 190,764 KB
最終ジャッジ日時 2025-01-09 17:59:17
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;
using lint=long long;

int main(){
	int q; cin>>q;
	rep(_,q){
		lint n,k; cin>>n>>k;
		lint ans=0;
		if(k==1) ans=n-1;
		else{
			lint sum=1;
			while(sum<n){
				sum=k*sum+1;
				ans++;
			}
		}
		cout<<ans<<'\n';
	}
	return 0;
}
0