using System; using System.Collections.Generic; using System.Linq; class Solution { internal struct State { internal int Cost; internal int Length; internal int CopiedLength; internal State(int c, int l, int cl) { Cost = c; Length = l; CopiedLength = cl; } } static void Main() { var n = int.Parse(Console.ReadLine()); var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); var c = vals[0]; var v = vals[1]; // cost -> length, copied length var states = new List() { { new State(0, 1, 0) } }; State best = states[0]; while (states.Count > 0) { var cur = states.OrderBy(s => s.Cost).First(); states.Remove(cur); if (cur.Length >= n) { best = cur; break; } // copy states.Add(new State(cur.Cost + c, cur.Length, cur.Length)); // paste states.Add(new State(cur.Cost + v, cur.Length + cur.CopiedLength, cur.CopiedLength)); } Console.WriteLine(best.Cost); } }