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) action = 0 # y方向の移動 action += y.abs / l action += 1 if 0 < (y.abs % l) # x方向の移動 action += x.abs / l action += 1 if 0 < (x.abs % l) # x方向の回転 action += 1 if x != 0 # y方向の回転 if y < 0 action += 1 #action += 1 if x == 0 end return (x == 0 and y == 0)? 0 : action end def dataoutput puts pilot(@x, @y, @l) end def run datainput dataoutput end end if $0 == __FILE__ PilotRobot.new.run end