n = read_line.to_i c, v = read_line.split.map &.to_i dp = Array.new(n + 1) { Hash(Int32, Int32).new(10 ** 9) } dp[2][1] = c + v (2...n).each do |len| dp[len].each do |clip, cost| dp[{len + clip, n}.min][clip] = {cost + v, dp[{len + clip, n}.min][clip]}.min dp[{len + len, n}.min][len] = {cost + c + v, dp[{len + len, n}.min][len]}.min end end puts dp[n].values.min