結果
| 問題 |
No.897 compαctree
|
| コンテスト | |
| ユーザー |
nasadigital
|
| 提出日時 | 2019-10-04 21:40:26 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 524 bytes |
| コンパイル時間 | 1,340 ms |
| コンパイル使用メモリ | 167,336 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-03 07:21:28 |
| 合計ジャッジ時間 | 1,861 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 13 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
ll q, n, k;
cin >> q;
for (int ctr1 = 0; ctr1 < q; ++ctr1) {
cin >> n >> k;
if (k == 1) {
cout << n - 1 << "\n";
continue;
}
ll cur = 1, rez = 0;
while (n > cur) {
n -= cur;
cur *= k;
++rez;
}
cout << rez << "\n";
}
return 0;
}
nasadigital