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 def g(n) rt=Array.new(n+1) (1..n).each do |e| rt[e]=f(e) end rt end dd=g(2*n) inf=10**18 dp=Array.new(2*n){inf} dp[0]=dp[1]=0 (2...(2*n)).each do |i| # dd=f(i) dd[i].each do |d| dp[i]=[dp[i], dp[d]+c+(i-1)/d*v].min end end puts dp[n...(2*n)].min