18/11/23 19:09:31.91 VH48PKdk.net
>>617 Ruby 再帰
def cost(x, y)
return [0] if x == 0
table = cost(x - 1, y)
table << table.flat_map.with_index{|e, i|
i == 0 ? [x] : [x / i, -(-x / i)].uniq.map{|v| e + v + y + (i * v - x).abs}
}.min
end
[[1,3], [3, 1], [20, 2], [