結果

問題 No.1253 雀見椪
ユーザー nehan_der_thalnehan_der_thal
提出日時 2020-10-09 22:38:20
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 386 ms / 2,000 ms
コード長 1,006 bytes
コンパイル時間 269 ms
コンパイル使用メモリ 87,248 KB
実行使用メモリ 79,632 KB
最終ジャッジ日時 2023-09-27 18:33:36
合計ジャッジ時間 5,437 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
71,116 KB
testcase_01 AC 71 ms
74,944 KB
testcase_02 AC 72 ms
75,316 KB
testcase_03 AC 116 ms
76,812 KB
testcase_04 AC 373 ms
78,908 KB
testcase_05 AC 379 ms
78,848 KB
testcase_06 AC 380 ms
79,632 KB
testcase_07 AC 382 ms
78,944 KB
testcase_08 AC 386 ms
78,928 KB
testcase_09 AC 383 ms
78,992 KB
testcase_10 AC 383 ms
78,892 KB
testcase_11 AC 386 ms
78,888 KB
testcase_12 AC 379 ms
79,088 KB
testcase_13 AC 379 ms
79,088 KB
testcase_14 AC 68 ms
71,248 KB
権限があれば一括ダウンロードができます

ソースコード

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
    ue = a*d+b*c
    si = b*d
    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))
#    print(x,y)
    px=P(x,y)-pa-pb
    x, y = padd((bx, by), (cx, cy))
#    print(x,y)
    py=P(x,y)-pb-pc
    x, y = padd((cx, cy), (ax, ay))
#    print(x,y)
    pz=P(x,y)-pc-pa
    print((1-px-py-pz)%MOD)

0