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 dpdp=dp[d]+c+(i-1)/d*v dp[i]=dpdp if dp[i]>dpdp end end puts dp[n...(2*n)].min =begin L+l*cn>=LL, cn>=(LL-L)/l ... V*cn L+L*cm>=LL, cm>=(LL-L)/L ... V*cm+C =end