gets d = gets.split.map(&:to_i) x1,y1 = gets.split.map(&:to_i) z = [x1+y1,x1-y1].map(&:abs).max if z==0 p 0;exit end if d.include?(z) p 1;exit end dmax = d.max d.each do |e| if z < e && ( z.odd? || (z.even? && e.even?)) p 2;exit end end if (((z+dmax-1)/dmax) <= 2) p ((z+dmax-1)/dmax) else p -1 end