func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long INF = 1e9, MAX = 100100, mod = 1000000007;   signed main() {     long long n, k, A, B;     cin >> n >> k >> A >> B;     long long ans = 0;     if (k == 1)       cout << (n - 1) * A;     else {       while (n != 1) {         if (n < k) {           ans = ans + (n - 1) * A;           n = 1;         } else if (n % k != 0) {           ans = ans + (n % k) * A;           n = n - n % k;         } else {           long long nis = n / k;           ans += min(B, (n - nis) * A);           n = n / k;         }       }       cout << ans;     }   }   