結果

問題 No.1253 雀見椪
ユーザー realDivineJKrealDivineJK
提出日時 2020-10-09 22:28:28
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,038 ms / 2,000 ms
コード長 850 bytes
コンパイル時間 88 ms
コンパイル使用メモリ 10,984 KB
実行使用メモリ 8,356 KB
最終ジャッジ日時 2023-09-27 18:16:33
合計ジャッジ時間 11,543 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
8,228 KB
testcase_01 AC 13 ms
8,356 KB
testcase_02 AC 16 ms
8,184 KB
testcase_03 AC 74 ms
8,236 KB
testcase_04 AC 1,037 ms
8,012 KB
testcase_05 AC 1,019 ms
7,800 KB
testcase_06 AC 1,032 ms
8,016 KB
testcase_07 AC 1,038 ms
7,988 KB
testcase_08 AC 1,020 ms
8,044 KB
testcase_09 AC 1,025 ms
7,956 KB
testcase_10 AC 1,036 ms
8,060 KB
testcase_11 AC 1,022 ms
8,176 KB
testcase_12 AC 1,023 ms
7,992 KB
testcase_13 AC 1,026 ms
8,036 KB
testcase_14 AC 15 ms
8,176 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = int(1e9) + 7
def doubling(n, m):
    y = 1
    bas = n
    while m:
        if m % 2:
            y *= bas
            y %= mod
        bas *= bas
        bas %= mod
        m >>= 1
    return y
def inved(a):
    x, y, u, v, k, l = 1, 0, 0, 1, a, mod
    while l:
        x, y, u, v, k, l = u, v, x - u * (k // l), y - v * (k // l), l, k % l
    return x % mod
T = int(input())
for _ in range(T):
    N, AG, BG, AC, BC, AP, BP = map(int, input().split())
    P = 1
    GP, CP, PP = AG * inved(BG) % mod, AC * inved(BC) % mod, AP * inved(BP) % mod
    P -= doubling(GP+CP, N) % mod
    P %= mod
    P -= doubling(CP+PP, N) % mod
    P %= mod
    P -= doubling(PP+GP, N) % mod
    P %= mod
    P += 2 * doubling(GP, N) % mod
    P %= mod
    P += 2 * doubling(CP, N) % mod
    P %= mod
    P += 2 * doubling(PP, N) % mod
    P %= mod
    print(P)
0