//include //------------------------------------------ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include 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; Lint d = 0; Lint sum = 1; Lint b = 1; while (sum < N) { d++; b *= K; sum += b; } cout << d << endl; } return 0; }