結果
問題 | No.897 compαctree |
ユーザー |
|
提出日時 | 2020-04-10 17:12:45 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 495 bytes |
コンパイル時間 | 729 ms |
コンパイル使用メモリ | 65,792 KB |
最終ジャッジ日時 | 2025-01-09 15:42:22 |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 13 |
ソースコード
#include <iostream> using lint = long long; void solve() { lint n, k; std::cin >> n >> k; if (k == 1) { std::cout << n - 1 << std::endl; return; } lint ch = 1, d = 0; while (true) { n -= ch; if (n <= 0) break; ch *= k; ++d; } std::cout << d << std::endl; } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); int q; std::cin >> q; while (q--) solve(); return 0; }