class PilotRobot attr_reader :x, :y, :l def initialize(x: 0, y: 0, l: 0) @x, @y, @l = x, y, l end def datainput begin @x = Integer(gets.chomp) @y = Integer(gets.chomp) @l = Integer(gets.chomp) rescue end end def pilot(x, y, l) return 0 if x == 0 and y == 0 action = 0 # y方向の移動 action += y.abs / l action += 1 if (y.abs % l) != 0 # x方向の移動 action += x.abs / l action += 1 if (x.abs % l) != 0 # x方向の回転 action += 1 if x != 0 # y方向の回転 if y < 0 action += 1 action += 1 if x == 0 end return action end def dataoutput puts pilot(@x, @y, @l) end def run datainput dataoutput end end if $0 == __FILE__ PilotRobot.new.run end