gets e=gets.split.map &:to_i d=[0,-1,0,1] until d.size>e.size d.size.times{|i|e[i+e.size-d.size]-=e[-1]/d[-1]*d[i]} e.pop end e.pop while e.size>1&&e[-1]==0 p e.size-1 puts e*' '