結果

問題 No.1253 雀見椪
ユーザー nehan_der_thalnehan_der_thal
提出日時 2020-10-09 22:30:50
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 986 bytes
コンパイル時間 285 ms
コンパイル使用メモリ 87,024 KB
実行使用メモリ 80,292 KB
最終ジャッジ日時 2023-09-27 18:20:24
合計ジャッジ時間 6,032 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,376 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from math import gcd
MOD = 10**9 + 7
def P(x,y):
    return div2(pow(x,n,MOD),pow(y,n,MOD))

def K(x,y):
    z=gcd(x,y)
    return x//z, y//z

def padd(x,y):
    a,b=x
    c,d=y
    x=gcd(b,d)
    ue = (a*b//x)+(c*d//x)
    si = b*d//x
    return K(ue, si)

def mul(a, b):
    return ((a % MOD) * (b % MOD)) % MOD

def div(a, b):
    return mul(a, pow(b, MOD-2, MOD))

def div2(a, b):
    return mul(a, modinv(b))

def modinv(a):
    b, u, v = MOD, 1, 0
    while b:
        t = a//b
        a, u = a-t*b, u-t*v
        a, b, u, v = b, a, v, u
    u %= MOD
    return u

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

    pa,pb,pc=P(ax,ay),P(bx,by),P(cx,cy)

    x, y = padd((ax, ay), (bx, by))
    px=P(x,y)-pa-pb
    x, y = padd((bx, by), (cx, cy))
    py=P(x,y)-pb-pc
    x, y = padd((cx, cy), (ax, ay))
    pz=P(x,y)-pc-pa
    print((1-px-py-pz)%MOD)

0