結果

問題 No.1253 雀見椪
ユーザー tonyu0tonyu0
提出日時 2020-10-09 22:36:06
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 620 ms / 2,000 ms
コード長 581 bytes
コンパイル時間 93 ms
コンパイル使用メモリ 10,700 KB
実行使用メモリ 7,960 KB
最終ジャッジ日時 2023-09-27 18:30:37
合計ジャッジ時間 7,528 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,776 KB
testcase_01 AC 16 ms
7,832 KB
testcase_02 AC 19 ms
7,960 KB
testcase_03 AC 56 ms
7,756 KB
testcase_04 AC 620 ms
7,748 KB
testcase_05 AC 619 ms
7,832 KB
testcase_06 AC 619 ms
7,924 KB
testcase_07 AC 620 ms
7,952 KB
testcase_08 AC 616 ms
7,936 KB
testcase_09 AC 617 ms
7,856 KB
testcase_10 AC 611 ms
7,756 KB
testcase_11 AC 619 ms
7,936 KB
testcase_12 AC 612 ms
7,808 KB
testcase_13 AC 614 ms
7,744 KB
testcase_14 AC 16 ms
7,824 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

t = int(input())
mod = 10 ** 9 + 7


def inv(x):
    return pow(x, mod - 2, mod)


for _ in range(t):
    n, ga, gb, ca, cb, pa, pb = map(int, input().split())
    g = ga * inv(gb)
    c = ca * inv(cb)
    p = pa * inv(pb)

    g_one = pow(g, n, mod)
    c_one = pow(c, n, mod)
    p_one = pow(p, n, mod)
    gc = (mod + pow(g + c, n, mod) - (g_one + c_one)) % mod
    gp = (mod + pow(g + p, n, mod) - (g_one + p_one)) % mod
    cp = (mod + pow(c + p, n, mod) - (c_one + p_one)) % mod
    gcp = (mod + pow(g + c + p, n, mod) -
           (gc + gp + cp) % mod) % mod
    print(gcp)
0