#include #define ll __int128 #define il inline #define ls p<<1 #define rs p<<1|1 const ll N = 1e5 + 10; const ll mod = 1e9+7; const ll inf = 2e18; using namespace std; void read(ll &x) { x = 0; char c = getchar(); ll f = 0; for (;!isdigit(c); c = getchar()) f |= c == '-'; for (; isdigit(c); c = getchar()) x = x*10 + (c ^ '0'); if (f) x = -x; } ll n, x, y, ans = inf; il bool solve(ll f, ll z) { ll a = z / f, b = z % f; ll numd = b, numz = f-b; ll res = 1; for (ll i = 1; i <= numd; i++) { res *= (a+2); if (res > n) return 1; } for (ll i = 1; i <= numz; i++) { res *= (a+1); if (res > n) return 1; } return 0; } int main() { // freopen("dice.in","r",stdin); // freopen("dice.out","w",stdout); read(x); read(y); read(n); ll len = log2((long long)n)+2; // O(logn * logn * logn) for (ll i = 1; i <= len; i++) { // ?????? ll l = i, r = n+1, res; while (l <= r) { // ?????? ll mid = (l + r) >> 1; if (solve(i, mid)) { r = mid-1; res = mid; } else { l = mid+1; } } //cout << i << " " << res << endl; ans = min(ans, i*x + res*y); } cout << (unsigned long long)ans << "\n"; return 0; } /* 1000000000000000000 2312241 2424211 */