結果

問題 No.61 リベリオン
ユーザー szkhtsszkhts
提出日時 2024-05-01 09:16:08
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 642 bytes
コンパイル時間 94 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 17,696 KB
最終ジャッジ日時 2024-05-01 09:16:15
合計ジャッジ時間 6,767 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,880 KB
testcase_01 AC 31 ms
10,752 KB
testcase_02 AC 32 ms
10,752 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

Q = int(input())

for _ in range(Q):
    w, h, d, mx, my, hx, hy, vx, vy = map(int, (input().split()))
    hit = [[0 for _ in range(w+1)] for _ in range(h+1)]
    
    k = math.gcd(abs(vx), abs(vy))
    d *= k
    vx //= k
    vy //= k
    
    for i in range(min(d + 1, 257 * 4)):
        dx = abs(hx + i * vx)                           
        dy = abs(hy + i * vy)
        dx %= 2 * w
        if(dx > w):
            dx = 2 * w - dx
        dy %= 2 * h
        if(dy > h):
            dy = 2 * h - dy
            
        hit[dy][dx] = 1
        
    if hit[my][mx] == 1:
        print("Hit")
    else:
        print("Miss")
0