結果

問題 No.1253 雀見椪
ユーザー 👑 rin204rin204
提出日時 2022-01-18 21:26:30
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 274 ms / 2,000 ms
コード長 487 bytes
コンパイル時間 397 ms
コンパイル使用メモリ 87,048 KB
実行使用メモリ 78,640 KB
最終ジャッジ日時 2023-08-15 07:39:24
合計ジャッジ時間 5,193 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
71,168 KB
testcase_01 AC 69 ms
71,092 KB
testcase_02 AC 64 ms
70,872 KB
testcase_03 AC 119 ms
76,108 KB
testcase_04 AC 269 ms
78,304 KB
testcase_05 AC 255 ms
78,148 KB
testcase_06 AC 250 ms
78,564 KB
testcase_07 AC 252 ms
78,044 KB
testcase_08 AC 256 ms
78,060 KB
testcase_09 AC 256 ms
77,956 KB
testcase_10 AC 274 ms
77,960 KB
testcase_11 AC 261 ms
78,148 KB
testcase_12 AC 274 ms
78,640 KB
testcase_13 AC 262 ms
78,024 KB
testcase_14 AC 67 ms
71,064 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 10 ** 9 + 7

def solve():
    n, ag, bg, ac, bc, ap, bp = map(int, input().split())
    G = (ag, bg)
    C = (ac, bc)
    P = (ap, bp)
    gcp = [G, C, P]
    ans = 0
    for i in range(3):
        g = gcp[i]
        tmp = (g[1] - g[0]) * pow(g[1], MOD - 2, MOD)
        ans += pow(tmp, n, MOD)
        tmp = g[0] * pow(g[1], MOD - 2, MOD)
        ans -= 2 * pow(tmp, n, MOD)
        ans %= MOD
    ans = 1 - ans
    print(ans % MOD)
    

for _ in range(int(input())):
    solve()
0