n=gets.to_i c, v=gets.split.map(&:to_i) def f(n) rt=[] (1..n).each do |i| break if i*i>n if n%i==0 rt<< i rt<< n/i end end rt end inf=10**18 dp=Array.new(2*n){inf} dp[0]=dp[1]=0 (2...(2*n)).each do |i| dd=f(i) dd.each do |d| r=(i-d+d-1)/d dp[i]=[dp[i], dp[d]+c+r*v].min end end puts dp[n...(2*n)].min