結果

問題 No.61 リベリオン
ユーザー maspymaspy
提出日時 2020-03-07 04:18:30
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 784 ms / 5,000 ms
コード長 675 bytes
コンパイル時間 251 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,648 KB
最終ジャッジ日時 2024-04-22 11:48:23
合計ジャッジ時間 2,581 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#!/usr/bin/env python3
# %%
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import itertools
from math import gcd

# %%
Q = int(readline())
query = readlines()


# %%
def solve(q):
    W, H, D, Mx, My, Hx, Hy, Vx, Vy = map(int, q.split())
    g = abs(gcd(Vx, Vy))
    Vx //= g
    Vy //= g
    D *= g
    ok_x = [Mx, W + W - Mx]
    ok_y = [My, H + H - My]
    for t in range(min(D + 1, 400)):
        x = (Hx + t * Vx) % (W + W)
        y = (Hy + t * Vy) % (H + H)
        if x in ok_x and y in ok_y:
            return True
    return False


# %%
for q in query:
    print('Hit' if solve(q) else 'Miss')
0