// Source: https://usaco.guide/general/io #include using namespace std; int main() { // yeeettt ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); // iad int a, b, n; cin >> a >> b >> n; if (n == 1) { cout << 0 << endl; return 0; } // temp answer int answer = a + (n - 1) * b; // iterate for (int use1 = 2; (1 << (use1 - 1)) <= n; use1++) { // dedlaratiom priority_queue, greater> pq; int duck = 1; int use2 = use1; for (int i = 1; i <= use1; i++) duck *= 2; for (int i = 1; i <= use1; i++) pq.push(2); // reiterate while (duck < n) { int now = pq.top(); pq.pop(); duck *= now + 1; duck /= now; use2 += 1; pq.push(now + 1); } // find the smallest valid one answer = min(answer, a * use1 + b * use2); } // final nail to the cofin cout << answer << endl; return 0; }