結果
| 問題 | No.48 ロボットの操縦 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-11-06 11:24:38 |
| 言語 | Ruby (4.0.6 + ACL) |
| 結果 |
WA
不安定
|
| 実行時間 | - |
| コード長 | 639 bytes |
| 記録 | |
| コンパイル時間 | 339 ms |
| コンパイル使用メモリ | 8,448 KB |
| 実行使用メモリ | 14,592 KB |
| 最終ジャッジ日時 | 2026-09-28 23:20:44 |
| 合計ジャッジ時間 | 9,612 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 2 WA * 1 TLE * 1 -- * 21 |
コンパイルメッセージ
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