結果
| 問題 |
No.897 compαctree
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-10-04 22:08:12 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 2,458 bytes |
| コンパイル時間 | 1,450 ms |
| コンパイル使用メモリ | 138,688 KB |
| 最終ジャッジ日時 | 2025-01-07 20:33:59 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 13 |
ソースコード
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <climits>
#include <set>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>
#include <locale>
#include <random>
#include <type_traits>
using namespace std;
#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}
using LL = long long;
//------------------------------------------
//------------------------------------------
typedef __int128 Lint;
Lint toLint(const string s) {
Lint ret = 0;
for (int i = 0; i < s.length(); i++)
if ('0' <= s[i] && s[i] <= '9')
ret = 10 * ret + s[i] - '0';
return ret;
}
ostream &operator<<(ostream &dest, __int128_t value) {
ostream::sentry s(dest);
if (s) {
__uint128_t tmp = value < 0 ? -value : value;
char buffer[128];
char *d = std::end(buffer);
do {
--d;
*d = "0123456789"[tmp % 10];
tmp /= 10;
} while (tmp != 0);
if (value < 0) {
--d;
*d = '-';
}
int len = std::end(buffer) - d;
if (dest.rdbuf()->sputn(d, len) != len) {
dest.setstate(ios_base::badbit);
}
}
return dest;
}
istream &operator>>(istream &in, Lint &d) {
string s;
cin >> s;
Lint tmp = 0;
for (int i = 0; i < s.length(); i++)if ('0' <= s[i] && s[i] <= '9')tmp = 10 * tmp + s[i] - '0';
d = tmp;
return in;
}
int main() {
LL Q;
cin >> Q;
while (Q--) {
Lint N, K;
cin >> N >> K;
if (K == 1) {
cout << N - 1 << endl;
continue;
}
Lint d = 0;
Lint sum = 1;
Lint b = 1;
while (sum < N) {
d++;
b *= K;
sum += b;
}
cout << d << endl;
}
return 0;
}