結果

問題 No.61 リベリオン
ユーザー gigurururugigurururu
提出日時 2014-11-10 14:06:43
言語 Ruby
(3.3.0)
結果
AC  
実行時間 695 ms / 5,000 ms
コード長 283 bytes
コンパイル時間 115 ms
コンパイル使用メモリ 7,296 KB
実行使用メモリ 12,416 KB
最終ジャッジ日時 2024-04-21 17:18:37
合計ジャッジ時間 2,374 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
12,288 KB
testcase_01 AC 86 ms
12,288 KB
testcase_02 AC 87 ms
12,288 KB
testcase_03 AC 695 ms
12,416 KB
testcase_04 AC 685 ms
12,288 KB
testcase_05 AC 85 ms
12,160 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

gets.to_i.times{
  w,h,d,mx,my,hx,hy,vx,vy=gets.split.map(&:to_i)
  gcd=vx.abs.gcd(vy.abs)

  puts (0..[d*gcd,(w+1)*(h+1)*4].min).any?{|i|
    (ansx=hx+vx/gcd*i)==(wn=ansx/w)*w+(wn%2==0?mx:(w-mx))&&
    (ansy=hy+vy/gcd*i)==(hn=ansy/h)*h+(hn%2==0?my:(h-my))
  }?"Hit":"Miss"
}
0