def solve(x, y, d) z = [x.abs, y.abs].max if z.zero? 0 elsif z < d 2 elsif z == d 1 else (z - 1) / d + 1 end end # m = 20 # M = 2 * m + 1 # d = 4 # f = [nil] * M # inf = 1000000000 # M.times{|i| f[i] = [inf] * M} # # f[m][m] = 0 # stack = [[m, m]] # # while not stack.empty? # x, y = stack.pop # (-d..d).each do |i| # (-d..d).each do |j| # next if i.abs != d && j.abs != d # x2 = x + i # y2 = y + j # next if x2 < -m || y2 < -m || x2 > 2*m || y2 > 2*m # if f[x2][y2] > f[x][y] + 1 # f[x2][y2] = f[x][y] + 1 # stack.push [x2, y2] # end # end # end # end # # # M.times do |i| # M.times do |j| # v = f[i][j] # if v.zero? # STDOUT.write sprintf "\e[31m%03d\e[0m ", v # elsif v.even? # STDOUT.write sprintf "\e[32m%03d\e[0m ", v # else # STDOUT.write sprintf "%03d ", v # end # end # puts "" # end _ = gets.to_i ds = gets.chomp.split.map(&:to_i) x, y = gets.chomp.split.map(&:to_i) p ds.map {|d| solve(x, y, d)}.min