#include #define FOR(i,bg,ed) for(ll i=(bg);i<(ed);i++) #define REP(i,n) FOR(i,0,n) #define MOD 1000000007 #define int long long using namespace std; typedef long long ll; typedef vector> mat; const int INF = 1e9; int N; int C, V; //X:コピーの回数 Y:ペーストの回数 でN文字以上を作れるか bool checkXY(int X, int Y) { int tmp = min(X, Y); //int can = 1, clip = (X > 0 ? 1 : 0); int can = 1, clip = 0; REP(i,tmp) { can *= 2; clip = can / 2; } if (Y - tmp > 0) { can += clip * (Y - tmp); } return N <= can; } //vのコストで作れるか bool checkV(int v) { for (int x=1; x<=v/C; x++) { //if (v - C * x < 0) break; int y = (v - C * x) / V; if (checkXY(x, y)) return true; } return false; } signed main() { cin >> N; cin >> C >> V; int lb = 0, ub = LONG_LONG_MAX; while (ub - lb > 1) { int mid = (lb + ub) / 2; if (checkV(mid)) ub = mid; else lb = mid; } cout << ub << endl; }