結果

問題 No.48 ロボットの操縦
ユーザー quilt-tails
提出日時 2016-09-30 18:25:29
言語 Ruby
(3.4.1)
結果
WA  
実行時間 -
コード長 548 bytes
コンパイル時間 153 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 12,416 KB
最終ジャッジ日時 2024-11-21 11:16:51
合計ジャッジ時間 3,469 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 24 WA * 1
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

num = STDIN.readlines.map(&:chomp)
X = num[0].to_i
Y = num[1].to_i
L = num[2].to_i
x = X.abs
y = Y.abs

count = 0
if Y > 0
  y_ans = Y.divmod(L)
  count += y_ans[0]
  if y_ans[1] > 0
    count += 1
  end
  count += 1 unless x == 0
  x_ans = x.divmod(L)
  count += x_ans[0]
  if x_ans[1] > 0
    count += 1
  end
  puts count
else
  count += 1
  x_ans = x.divmod(L)
  count += x_ans[0]
  if x_ans[1] > 0
    count += 1
  end
  count += 1 unless y == 0
  y_ans = y.divmod(L)
  count += y_ans[0]
  if y_ans[1] > 0
    count += 1
  end
  puts count
end
0