#include using namespace std; void solve() { int a, b, n; cin >> a >> b >> n; // if your lucky if (n == 1) { cout << 0 << endl; return; } // temp answer int answer = a + (n - 1) * b; // start iterating for (int use_a = 2; (1 << (use_a - 1)) <= n; use_a++) { priority_queue, greater> pq; int pr = 1; int use_b = use_a; for (int i = 1; i <= use_a; i++) pr *= 2; for (int i = 1; i <= use_a; i++) pq.push(2); while (pr < n) { int cur = pq.top(); pq.pop(); pr *= cur + 1; pr /= cur; use_b += 1; pq.push(cur + 1); } // looking for min answer = min(answer, a * use_a + b * use_b); } // couting final answer cout << answer << endl; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); solve(); return 0; }