class A def initialize n, d, k = gets.chomp.split(' ').map(&:to_i) answer = [*(1..k-1)] + [d-(1..k-1).inject(:+)] diff = answer.last - n if diff > 0 answer[-1] -= diff (k-2).downto(0) do |index| sub = [diff, (answer[index+1] - 1) - answer[index]].min answer[index] += sub diff -= sub break if diff.zero? end end if answer.inject(:+) == d and answer.uniq.size == k and answer.all?{|i| i > 0} puts answer.join(' ') else puts -1 end end end A.new