結果

問題 No.48 ロボットの操縦
ユーザー jomjomni
提出日時 2025-08-31 08:46:33
言語 Ruby
(3.4.1)
結果
AC  
実行時間 86 ms / 5,000 ms
コード長 914 bytes
コンパイル時間 251 ms
コンパイル使用メモリ 8,064 KB
実行使用メモリ 13,056 KB
最終ジャッジ日時 2025-08-31 08:46:37
合計ジャッジ時間 3,646 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 25
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

x=gets.to_i
y=gets.to_i
distance=gets.to_f
order=0

def custom_round(num)
  if num < 1
    return 1
  else
    return num.ceil
  end
end

if x == 0 && y == 0
  puts order
elsif y == 0 && x > 0
  order += 1
  puts order + custom_round(x / distance)
elsif y == 0 && x < 0
  order += 1
  puts order + custom_round(x.abs / distance)
elsif x == 0 && y > 0
  puts order + custom_round(y / distance)
elsif x == 0 && y < 0
  order += 2
  puts order + custom_round(y.abs / distance)
elsif x > 0 && y > 0
  order += 1
  puts order + custom_round(x / distance) + custom_round(y / distance)
elsif x < 0 && y > 0
  order += 1
  puts order + custom_round(x.abs / distance) + custom_round(y / distance)
elsif x < 0 && y < 0
  order += 2
  puts order + custom_round(x.abs / distance) + custom_round(y.abs / distance)
elsif x > 0 && y < 0
  order += 2
  puts order + custom_round(x / distance) + custom_round(y.abs / distance)
end
0