結果

問題 No.897 compαctree
コンテスト
ユーザー mmn15277198
提出日時 2021-01-21 21:39:40
言語 C++14
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -fplugin=/usr/lib/yukicoder/noavx512-gcc15.so -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 479 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 357 ms
コンパイル使用メモリ 93,904 KB
実行使用メモリ 9,796 KB
最終ジャッジ日時 2026-10-12 07:48:08
合計ジャッジ時間 1,496 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 14 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <vector>
#include <math.h>
using namespace std;
using ll = long long;
vector<int> ans;
void solve(ll n , ll k){
	if(k == 1){
		ans.push_back(n - 1);
		return;
	}
	if(k >= 2){
		n -= 1;
		int res = 0;
		while(n > 0){
			n /= k;
			res++;
		}
		ans.push_back(res);
		return;
	}
}
int main(){
	int q;
	cin >> q;
	while(q--){
		ll n , k;
		cin >> n >> k;
		solve(n , k);
	}
	for(int i = 0; i < ans.size(); i++){
		cout << ans[i] << endl;
	}
	return 0;
}
0