結果

問題 No.61 リベリオン
ユーザー gigurururugigurururu
提出日時 2014-11-10 01:40:44
言語 Ruby
(3.3.0)
結果
AC  
実行時間 2,300 ms / 5,000 ms
コード長 343 bytes
コンパイル時間 113 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 12,288 KB
最終ジャッジ日時 2024-04-21 17:17:58
合計ジャッジ時間 5,975 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

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