K = gets.to_i def search (1 .. 30).each do |n| (0 .. n).each do |z| return Array.new(z, 0) + Array.new(n - z, 1) if 2 ** z * (n - z) * (n - z - 1) == K * 2 end end end puts search * ' '