結果
問題 | No.897 compαctree |
ユーザー |
![]() |
提出日時 | 2019-10-04 21:24:28 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 448 bytes |
コンパイル時間 | 398 ms |
コンパイル使用メモリ | 54,768 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-03 07:08:29 |
合計ジャッジ時間 | 969 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 13 |
ソースコード
#include <iostream>using namespace std;typedef long long ll;int main(){int Q;cin >> Q;for(int i=0;i<Q;i++){ll n,k;cin >> n >> k;ll node = 1;ll ans = 1;ll sum = 1;if(k==1){cout << n-1 << endl;continue;}while(sum<n){node *= k;sum += node;ans++;}cout << --ans << endl;}}