結果
| 問題 | No.48 ロボットの操縦 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-11-06 11:24:38 |
| 言語 | Ruby (3.4.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 639 bytes |
| 記録 | |
| コンパイル時間 | 37 ms |
| コンパイル使用メモリ | 7,552 KB |
| 実行使用メモリ | 24,064 KB |
| 最終ジャッジ日時 | 2024-11-24 03:06:48 |
| 合計ジャッジ時間 | 8,876 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 18 WA * 6 TLE * 1 |
コンパイルメッセージ
Syntax OK
ソースコード
class No48
attr_accessor :width, :height, :distance, :count
def initialize
@width, @height, @distance = gets.chomp.to_i, gets.chomp.to_i, gets.chomp.to_i
@count = 0
end
def negative_number(num)
if num < 0
num *= -1
@count += 1
end
num
end
def move_on(num)
unless num == 0
num < @distance ? num = 0 : num -= @distance
@count += 1
end
num
end
def run
@width = self.negative_number(@width)
@height = self.negative_number(@height)
loop{
@width = self.move_on(@width)
@height = self.move_on(@height)
break if @width == 0 && @height == 0
}
@count
end
end
no48 = No48.new
puts no48.run