結果
| 問題 |
No.61 リベリオン
|
| コンテスト | |
| ユーザー |
ytft
|
| 提出日時 | 2022-11-07 02:56:16 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,609 bytes |
| コンパイル時間 | 265 ms |
| コンパイル使用メモリ | 82,136 KB |
| 実行使用メモリ | 68,296 KB |
| 最終ジャッジ日時 | 2024-07-20 13:05:55 |
| 合計ジャッジ時間 | 1,292 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 RE * 1 |
| other | RE * 4 |
ソースコード
import sys
input=lambda:sys.stdin.readline().rstrip()
def gcd(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,c):
if a==b==0:
return [[1,1],-1][c!=0]
if a<0 or b<0:
temp=euclid(abs(a),abs(b),c)
return -1 if temp==-1 else [[1,-1][a<0]*temp[0],[1,-1][b<0]*temp[1]]
if a==0:
return -1 if c%b else [0,c//b]
if b==0:
return -1 if c%a else [c//a,0]
if b>a:
temp=euclid(a,b%a,c)
return -1 if temp==-1 else [temp[0]-(b//a)*temp[1],temp[1]]
else:
temp=euclid(a%b,b,c)
return -1 if temp==-1 else [temp[0],temp[1]-(a//b)*temp[0]]
def calc(a,b,ma,mb,ra,rb):
#print(a,b,ma,mb,ra,rb)
a%=ma
b%=mb
ra%=ma
rb%=mb
#print(a,b,ma,mb,ra,rb)
k=[euclid(a,-ma,ra),euclid(b,-mb,rb)]
#print(k[0][0],k[1][0])
if -1 in k:
return float('inf')
#print(ma//gcd(ma,a),-mb//gcd(mb,b),k[1][0]-k[0][0])
l=euclid(ma//gcd(ma,a),-mb//gcd(mb,b),k[1][0]-k[0][0])
#print(l)
if l==-1:
return float('inf')
ret=l[0]*a//gcd(ma,a)+k[0][0]
#print(ret,lcm(gcd(ma,a),gcd(mb,b)))
ret%=lcm(a//gcd(ma,a),b//gcd(mb,b))
#print(ret)
return ret
def solve():
temp=list(map(int,input().split()))
g=gcd(abs(temp[7]),abs(temp[8]))
temp[2]*=g
temp[7]//=g
temp[8]//=g
test=[[temp[3]-temp[5],2*temp[0]-temp[3]-temp[5]],[temp[4]-temp[6],2*temp[1]-temp[4]-temp[6]]]
flg=0
for i in range(4):
cur=[test[0][i//2],test[1][i%2]]
flg|=(calc(temp[7],temp[8],2*temp[0],2*temp[1],*cur)<=temp[2])
print(["Miss","Hit"][flg])
#print(euclid(9,10,9))
N=int(input())
for i in range(N):
solve()
ytft