結果

問題 No.1253 雀見椪
ユーザー maspymaspy
提出日時 2020-08-24 16:03:29
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 539 ms / 2,000 ms
コード長 653 bytes
コンパイル時間 232 ms
コンパイル使用メモリ 10,904 KB
実行使用メモリ 8,360 KB
最終ジャッジ日時 2023-09-27 09:04:57
合計ジャッジ時間 7,497 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,952 KB
testcase_01 AC 17 ms
7,820 KB
testcase_02 AC 18 ms
7,856 KB
testcase_03 AC 49 ms
8,196 KB
testcase_04 AC 539 ms
8,360 KB
testcase_05 AC 534 ms
8,204 KB
testcase_06 AC 528 ms
8,256 KB
testcase_07 AC 530 ms
8,184 KB
testcase_08 AC 533 ms
8,360 KB
testcase_09 AC 534 ms
8,172 KB
testcase_10 AC 529 ms
8,196 KB
testcase_11 AC 534 ms
8,200 KB
testcase_12 AC 537 ms
8,264 KB
testcase_13 AC 535 ms
8,176 KB
testcase_14 AC 15 ms
7,868 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

MOD = 1_000_000_007

def frac_mod(a, b):
    return a * pow(b, MOD - 2, MOD) % MOD

def solve(N, pg, pc, pp):
    g = pow(pg, N, MOD)
    c = pow(pc, N, MOD)
    p = pow(pp, N, MOD)
    gc = pow(pg + pc, N, MOD) - g - c
    gp = pow(pg + pp, N, MOD) - g - p
    cp = pow(pc + pp, N, MOD) - c - p
    tie = 1 - gc - gp - cp
    return tie % MOD

T = int(readline())
for _ in range(T):
    N, a, b, c, d, e, f = map(int, readline().split())
    g, c, p = (frac_mod(a, b) for a, b in ((a, b), (c, d), (e, f)))
    print(solve(N, g, c, p))
0