#include #include #ifndef LOCAL #define file_name "" #define csf \ { \ std::cerr.setstate(std::ios_base::failbit); \ if (file_name != "") \ freopen(file_name ".in", "r", stdin), freopen(file_name ".out", "w", stdout); \ } #define db(x) #else #define db(x) cerr << __FUNCTION__ << " L" << __LINE__ << " " << #x " = " << (x) << endl #define csf #endif #define ll long long #define unordered_map __gnu_pbds::gp_hash_table #define f(x, y, z) for (ll x = (y); x <= (z); x++) inline ll read(); using namespace std; using __ = __int128; const long long INF = 0x3f3f3f3f3f3f3f3f, M = 65; ll n, a, b; __ ans = INF; bool check(ll x, ll y) { //????? ll a = y / x, b = y % x; __ res = 1; f(i, 1, x - b) { res *= a + 1; if (res > 1e18) return 1; } f(i, 1, b) { res *= a + 2; if (res > 1e18) return 1; } return res >= n; } signed main() { csf; cin>>a>>b>>n; n--; f(i, 1, 65) { //????? ll l = i, r = n, mid, ans; while (l <= r) { mid = (l + r) / 2; if (check(i, mid)) { ans = mid; r = mid - 1; } else l = mid + 1; } ::ans = min(::ans, (__)a * i + (__)b * ans); } cout << (ll)ans << endl; return 0; } /* ????????? ?????? ????? 1 ????????? 3 ????23?????? ????????????????w????v????????????v/w????? ???k??? ???? x + k * y???? k + 1 x = 3, y = 1 k = 3 4 / 6 6 / 8 --------------- ??????? ??????? ?????? ??????????? */