結果

問題 No.61 リベリオン
ユーザー ytftytft
提出日時 2022-11-06 21:14:47
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 1,322 bytes
コンパイル時間 252 ms
コンパイル使用メモリ 86,948 KB
実行使用メモリ 79,140 KB
最終ジャッジ日時 2023-09-27 14:42:30
合計ジャッジ時間 1,695 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 70 ms
71,180 KB
testcase_02 AC 67 ms
71,320 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=lambda:sys.stdin.readline().rstrip()
def gcd(a,b):
	if a*b==0:
		return a+b
	return gcd(a%b,b%a) if min(a,b,abs(a-b)) else max(a,b)
def lcm(a,b):
	return a*b//gcd(a,b)
def euclid(a,b):
	if a<0:
		temp=euclid(-a,b)
		return [-temp[0],temp[1]]
	if b<0:
		temp=euclid(a,-b)
		return [temp[0],-temp[1]]
	if a==1:
		return [1,0]
	if b==1:
		return [0,1]
	if a*b==0:
		return -1
	if b>a:
		temp=euclid(a,b%a)
		return [temp[0]-(b//a)*temp[1],temp[1]]
	else:
		temp=euclid(a%b,b)
		return [temp[0],temp[1]-(a//b)*temp[0]]
def calc(W,M,H,V):
	ans=[0 for i in range(2)]
	g=gcd(abs(V),abs(2*W))
	right=[M-H,2*W-M-H]
	for i in range(2):
		if right[i]%g:
			ans[i]=-1
			continue
		right[i]//=g
		ans[i]=[(euclid(V//g,2*W//g)[0]*right[i])%W,W]
	return ans
def solve():
	temp=list(map(int,input().split()))
	temp[:3]=[temp[2]]+temp[:2]
	g=gcd(abs(temp[7]),abs(temp[8]))
	temp[0]*=g
	temp[7]//=g
	temp[8]//=g
	flg=0
	r=[calc(*temp[i::2]) for i in range(1,3)]
	for i in range(4):
		ret=[r[0][i%2],r[1][i//2]]
		if -1 in ret:
			continue
		if (ret[0][0]-ret[1][0])%gcd(abs(ret[0][1]),abs(ret[1][1])):
			continue
		R=euclid(ret[0][1],-ret[1][1])[0]*(ret[1][0]-ret[0][0])*ret[0][1]+ret[0][0]
		R%=lcm(abs(ret[0][1]),abs(ret[1][1]))
		flg|=(R<=temp[0])
	print(["Miss","Hit"][flg])
N=int(input())
for i in range(N):
	solve()
0