結果

問題 No.1253 雀見椪
ユーザー brthyyjpbrthyyjp
提出日時 2020-10-09 23:21:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 277 ms / 2,000 ms
コード長 534 bytes
コンパイル時間 276 ms
コンパイル使用メモリ 87,176 KB
実行使用メモリ 79,148 KB
最終ジャッジ日時 2023-09-27 19:45:25
合計ジャッジ時間 4,253 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
71,360 KB
testcase_01 AC 64 ms
71,160 KB
testcase_02 AC 66 ms
71,240 KB
testcase_03 AC 104 ms
76,184 KB
testcase_04 AC 277 ms
79,144 KB
testcase_05 AC 265 ms
78,940 KB
testcase_06 AC 259 ms
78,804 KB
testcase_07 AC 257 ms
79,148 KB
testcase_08 AC 267 ms
79,028 KB
testcase_09 AC 268 ms
78,892 KB
testcase_10 AC 263 ms
78,944 KB
testcase_11 AC 262 ms
79,004 KB
testcase_12 AC 271 ms
78,892 KB
testcase_13 AC 273 ms
78,984 KB
testcase_14 AC 68 ms
71,196 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

t = int(input())
mod = 10**9+7
for _ in range(t):
    n, ag, bg, ac, bc, ap, bp = map(int, input().split())
    p1 = (bp-ap)*pow(bp, mod-2, mod)
    p1 = pow(p1, n, mod)
    p2 = ap*pow(bp, mod-2, mod)
    p2 = pow(p2, n, mod)

    c1 = (bc-ac)*pow(bc, mod-2, mod)
    c1 = pow(c1, n, mod)
    c2 = ac*pow(bc, mod-2, mod)
    c2 = pow(c2, n, mod)

    g1 = (bg-ag)*pow(bg, mod-2, mod)
    g1 = pow(g1, n, mod)
    g2 = ag*pow(bg, mod-2, mod)
    g2 = pow(g2, n, mod)

    ans = 1-p1-c1-g1+2*p2+2*c2+2*g2
    ans %= mod
    print(ans)
0