結果

問題 No.1253 雀見椪
ユーザー tktk_snsntktk_snsn
提出日時 2021-04-23 21:03:33
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 476 ms / 2,000 ms
コード長 665 bytes
コンパイル時間 83 ms
コンパイル使用メモリ 11,012 KB
実行使用メモリ 8,336 KB
最終ジャッジ日時 2023-09-17 11:19:44
合計ジャッジ時間 6,088 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,792 KB
testcase_01 AC 15 ms
7,812 KB
testcase_02 AC 16 ms
7,904 KB
testcase_03 AC 43 ms
8,236 KB
testcase_04 AC 475 ms
8,308 KB
testcase_05 AC 474 ms
8,236 KB
testcase_06 AC 473 ms
8,288 KB
testcase_07 AC 474 ms
8,256 KB
testcase_08 AC 475 ms
8,196 KB
testcase_09 AC 474 ms
8,308 KB
testcase_10 AC 474 ms
8,184 KB
testcase_11 AC 473 ms
8,336 KB
testcase_12 AC 474 ms
8,316 KB
testcase_13 AC 476 ms
8,236 KB
testcase_14 AC 16 ms
7,852 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)
mod = 10**9 + 7


def test():
    N, Ag, Bg, Ac, Bc, Ap, Bp = map(int, input().split())
    pg = Ag * pow(Bg, -1, mod) % mod
    pc = Ac * pow(Bc, -1, mod) % mod
    pp = Ap * pow(Bp, -1, mod) % mod

    res = 0
    g = pow(pg, N, mod)
    c = pow(pc, N, mod)
    p = pow(pp, N, mod)

    gc = pow(pg+pc, N, mod) - g - c
    cp = pow(pc+pp, N, mod) - c - p
    pg = pow(pp+pg, N, mod) - p - g
    gc %= mod
    cp %= mod
    pg %= mod

    gcp = 1 - (gc + cp + pg + g + c + p) % mod
    gcp %= mod
    return (g + c + p + gcp) % mod


T = int(input())
for _ in range(T):
    print(test())
0