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) (1..i).each do |dd| # r=(i-d+d-1)/d # dp[i]=[dp[i], dp[d]+c+r*v].min break if dd*dd>i next if i%dd!=0 d=i/dd dpdp=dp[d]+c+(i-1)/d*v dp[i]=dpdp if dp[i]>dpdp if d!=dd dpdp=dp[dd]+c+(i-1)/dd*v dp[i]=dpdp if dp[i]>dpdp end 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