#include #include #include #include using namespace std; const int MAXN = 1e5 + 10; // 55pts const int64_t INF = 1e18; int64_t f[MAXN]; int k_v[MAXN]; int64_t fstpow(int a, int k) { if (k == 0) return 1; if (k == 1) return a; int64_t tmp = fstpow(a, k / 2); if (tmp < 0) return -1; if (k % 2 == 0) return tmp * tmp; else return tmp * tmp * a; } int64_t rpow(int64_t a, int64_t k) { int64_t l = 1, r = a; while (l < r) { int64_t mid = (l + r) / 2; int64_t t = fstpow(mid, k); if (t < a && t > 0) l = mid + 1; else r = mid; } return l; } int main() { // freopen("dice.in", "r", stdin); // freopen("dice.out", "w", stdout); int64_t n, x, y; // cin >> n >> x >> y; int64_t ans = INF; cin >> x >> y >> n; n -= 1; for (int i = 1; (1 << i) < n * 2; ++i) { int64_t v = rpow(n, i); int64_t lst = fstpow(v, i - 1); int64_t now = i * x + (i - 1) * y * (v - 1) + ((int64_t)floor((double)n / lst)) * y; cerr << "dbg: " << i << " " << v << " " << now << "\n"; ans = min(ans, now); } cout << ans << "\n"; return 0; }