結果
問題 | No.897 compαctree |
ユーザー |
![]() |
提出日時 | 2019-10-07 05:38:08 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 732 bytes |
コンパイル時間 | 1,443 ms |
コンパイル使用メモリ | 158,568 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-12 08:21:28 |
合計ジャッジ時間 | 2,049 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 13 |
ソースコード
#include "bits/stdc++.h" using namespace std; typedef long long int ll; typedef vector<ll> vl; typedef pair<ll, ll> P; #define rep(i,n) for(ll i = 0; i < ll(n); i++) #define all(v) v.begin() , v.end() #define inputv(v,n) rep(i,n){\ ll x;\ cin>>x;\ v.push_back(x);\ } const ll INF = 99999999999999; const ll MOD = 1000000007; ll a, b, c, d, e, f, p, q, t, k, m, n, ans = 0; vl N, K; void input(void) { cin >> q; } void solve(void){ while (q--) { cin >> n >> k; if (k == 1) { cout << n - 1 << endl; } else { a = 1; ans = -1; while (n > 0) { n -= a; a = a * k; ans++; } cout << ans << endl; } } } int main() { cin.tie(0); ios::sync_with_stdio(false); input(); solve(); }