結果

問題 No.1253 雀見椪
ユーザー r_ishidar_ishida
提出日時 2020-12-30 10:16:21
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 921 ms / 2,000 ms
コード長 787 bytes
コンパイル時間 314 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-04-16 07:05:02
合計ジャッジ時間 10,900 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,624 KB
testcase_01 AC 31 ms
10,752 KB
testcase_02 AC 33 ms
10,624 KB
testcase_03 AC 82 ms
10,752 KB
testcase_04 AC 919 ms
10,752 KB
testcase_05 AC 912 ms
10,752 KB
testcase_06 AC 917 ms
10,752 KB
testcase_07 AC 921 ms
10,752 KB
testcase_08 AC 917 ms
10,752 KB
testcase_09 AC 914 ms
10,752 KB
testcase_10 AC 916 ms
10,752 KB
testcase_11 AC 912 ms
10,752 KB
testcase_12 AC 911 ms
10,752 KB
testcase_13 AC 917 ms
10,752 KB
testcase_14 AC 30 ms
10,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

t = I()
MOD = 10**9+7

for _ in range(t):
    n, ag, bg, ac, bc, ap, bp = MI()
    g1 = pow(bg-ag, n, MOD)
    g0 = pow(bg,n,MOD)
    g2 = pow(g0, MOD-2, MOD)
    c1 = pow(bc-ac, n, MOD)
    c0 = pow(bc,n,MOD)
    c2 = pow(c0, MOD-2, MOD)
    p1 = pow(bp-ap, n, MOD)
    p0 = pow(bp,n,MOD)
    p2 = pow(p0, MOD-2, MOD)

    ans = 1-(g1*g2)%MOD-(c1*c2)%MOD-(p1*p2)%MOD+2*pow(ag,n, MOD)*g2+2*pow(ac,n, MOD)*c2+2*pow(ap,n, MOD)*p2
    ans %= MOD
    print(ans)
0