func_code_string: #include <bits/stdc++.h>   using namespace std;   string to_string(string s) { return     + s +    ; }   string to_string(const char *s) { return to_string((string)s); }   string to_string(bool b) { return (b ?  true  :  false ); }   template <typename A, typename B>   string to_string(pair<A, B> p) {     return  (  + to_string(p.first) +  ,   + to_string(p.second) +  ) ;   }   template <typename A, typename B, typename C>   string to_string(tuple<A, B, C> t) {     return  (  + to_string(get<0>(t)) +  ,   + to_string(get<1>(t)) +  ,   +            to_string(get<2>(t)) +  ) ;   }   template <typename A>   string to_string(A v) {     bool first = true;     string res =  { ;     for (const auto &x : v) {       if (!first) {         res +=  ,  ;       }       first = false;       res += to_string(x);     }     res +=  } ;     return res;   }   void _debug() { cerr <<   n ; }   template <typename Head, typename... Tail>   void _debug(Head H, Tail... T) {     cerr <<     << to_string(H);     _debug(T...);   }   using ll = long long;   using ld = long double;   using ii = pair<int, int>;   using vi = vector<int>;   using vii = vector<ii>;   using vc = vector<char>;   using vb = vector<bool>;   int main() {     cin.tie(nullptr);     ios::sync_with_stdio(false);     cout << fixed << setprecision(9);     int n, k;     cin >> n >> k;     int lo = 1, hi = n;     while (lo < hi) {       int mid = lo + (hi - lo) / 2;       int total = 0;       int cur = mid;       while (cur) {         total += cur;         cur /= k;       }       if (total >= n) {         hi = mid;       } else {         lo = mid + 1;       }     }     cout << hi;   }   