結果
| 問題 |
No.897 compαctree
|
| コンテスト | |
| ユーザー |
Nachia
|
| 提出日時 | 2020-09-27 15:51:25 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 533 bytes |
| コンパイル時間 | 1,559 ms |
| コンパイル使用メモリ | 166,840 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-30 12:39:33 |
| 合計ジャッジ時間 | 2,223 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 13 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)
int main() {
int Q; cin >> Q;
while (Q--) {
LL N, K; cin >> N >> K;
LL t = 1;
LL ans = 0;
if (K == 1) ans = N - 1;
else {
while (true) {
N = max(0ll, N - t);
if (N == 0) break;
ans++;
t *= K;
}
}
cout << ans << endl;
}
return 0;
}
Nachia