結果

問題 No.3180 angles sum
ユーザー detteiuu
提出日時 2025-06-24 18:21:45
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,514 ms / 2,000 ms
コード長 2,556 bytes
コンパイル時間 363 ms
コンパイル使用メモリ 82,364 KB
実行使用メモリ 80,044 KB
最終ジャッジ日時 2025-06-24 18:22:09
合計ジャッジ時間 22,086 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd

class Fraction:
    def __init__(self, top, bottom):
        self.top = top
        self.bottom = bottom

def to_fraction(n):
    if type(n) == int:
        return Fraction(n, 1)
    else:
        return n

def compare(L, R):
    L, R = to_fraction(L), to_fraction(R)
    a = L.top*R.bottom
    b = L.bottom*R.top
    if a < b:
        return -1
    elif a == b:
        return 0
    else:
        return 1
    
def max_f(L, R):
    return L if compare(L, R) == 1 else R

def min_f(L, R):
    return L if compare(L, R) == -1 else R

def ADD(L, R):
    L, R = to_fraction(L), to_fraction(R)
    l, r = L.bottom, R.bottom
    lt = L.top*r
    rt = R.top*l
    top = lt+rt
    bottom = l*r
    GCD = gcd(top, bottom)
    top //= GCD
    bottom //= GCD
    return Fraction(top, bottom)

def SUB(L, R):
    L, R = to_fraction(L), to_fraction(R)
    l, r = L.bottom, R.bottom
    lt = L.top*r
    rt = R.top*l
    top = lt-rt
    bottom = l*r
    GCD = gcd(top, bottom)
    top //= GCD
    bottom //= GCD
    return Fraction(top, bottom)

def MUL(L, R):
    L, R = to_fraction(L), to_fraction(R)
    top = L.top*R.top
    bottom = L.bottom*R.bottom
    GCD = gcd(top, bottom)
    top //= GCD
    bottom //= GCD
    return Fraction(top, bottom)

def DIV(L, R):
    L, R = to_fraction(L), to_fraction(R)
    top = L.top*R.bottom
    bottom = L.bottom*R.top
    GCD = gcd(top, bottom)
    top //= GCD
    bottom //= GCD
    return Fraction(top, bottom)

def decimal(F):
    return F.top/F.bottom

for _ in range(int(input())):
    ax, ay, bx, by, cx, cy = map(int, input().split())
    
    if bx == 0:
        ax, ay, bx, by = bx, by, ax, ay

    if ax == 0:
        if bx == 0:
            if cx < 0 and cy == 0:
                print("Yes")
            else:
                print("No")
        elif 1 <= bx:
            a, b = -by, bx
            if (a, b) == (cx, cy):
                print("Yes")
            else:
                print("No")
        else:
            print("No")
    elif cx == 0:
        if compare(MUL(Fraction(ay, ax), Fraction(by, bx)), 1) == 0:
            print("Yes")
        else:
            print("No")
    elif cy == 0:
        if 1 <= cx:
            if ay == by == 0:
                print("Yes")
            else:
                print("No")
        else:
            print("No")
    else:
        if compare(ADD(Fraction(ay, ax), Fraction(by, bx)), SUB(Fraction(cy, cx), MUL(MUL(Fraction(ay, ax), Fraction(by, bx)), Fraction(cy, cx)))) == 0:
            print("Yes")
        else:
            print("No")
0