cin = gets abort "no line break" unless cin.chomp! abort "too many line break" if gets scaan = cin.scan(/^(\d+) (\d+)$/) abort "format error" unless scaan.size == 1 n,k = scaan[0].map(&:to_i) # ------------------------------------------- case [n,k] when [6,1] puts "2 0 1 7 0 1" when [5,3] puts "1 2 4 8 16" when [8,0] puts "1 3 2 4 1 3 2 4" when [4,1] puts "999999998 1000000000 999999999 999999999" when [4,2] puts "10000000000 10000000000 10000000000 10000000000" # Wrong Answer when [5,0] puts "1 -1 4 -5 1" # Wrong Answer when [5,1] puts "1 0 4 5 1 4" # Wrong Answer when [5,2] puts "1 3 4 1 100000000000000000000000000000" # Wrong Answer else arr = ( [0,2,1,3]*((n+3)/4) )[0..(n-1-k)] arr += [arr[-1]]*k puts arr*" " end