結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
7,916 KB
testcase_01 AC 16 ms
7,744 KB
testcase_02 AC 18 ms
7,680 KB
testcase_03 AC 49 ms
7,684 KB
testcase_04 AC 541 ms
7,744 KB
testcase_05 AC 552 ms
7,820 KB
testcase_06 AC 537 ms
7,916 KB
testcase_07 AC 545 ms
7,920 KB
testcase_08 AC 548 ms
7,904 KB
testcase_09 AC 545 ms
7,768 KB
testcase_10 AC 540 ms
7,944 KB
testcase_11 AC 537 ms
7,832 KB
testcase_12 AC 545 ms
7,856 KB
testcase_13 AC 533 ms
7,872 KB
testcase_14 AC 15 ms
7,972 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 + 1 - (gc + gp + cp) % mod) % mod
    print(gcp)
0