func_code_string: #include <bits/stdc++.h>   using namespace std;   long long n, k, A, B, ans = 0;   long long fmin() {     long long pros = (n - (n / k)) * A;     if (B < pros) {       n = n / k;       return B;     } else {       n = n / k;       return pros;     }   }   int main() {     cin >> n;     cin >> k;     cin >> A;     cin >> B;     if (k == 1) {       cout << (n - 1) * A;       return 0;     }     while (n != 1) {       if (n >= k) {         if (n % k == 0) {           ans += fmin();         } else {           long long t = (n % k);           n = n - t;           ans += (A * t);         }       } else {         ans = ans + (n - 1) * A;         n = 1;       }     }     cout << ans;     return 0;   }   