結果

問題 No.1253 雀見椪
ユーザー KudeKude
提出日時 2020-10-09 22:09:47
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 267 ms / 2,000 ms
コード長 494 bytes
コンパイル時間 267 ms
コンパイル使用メモリ 87,364 KB
実行使用メモリ 81,136 KB
最終ジャッジ日時 2023-09-27 17:31:43
合計ジャッジ時間 4,167 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
71,392 KB
testcase_01 AC 65 ms
71,272 KB
testcase_02 AC 64 ms
71,232 KB
testcase_03 AC 104 ms
77,524 KB
testcase_04 AC 261 ms
80,936 KB
testcase_05 AC 261 ms
80,884 KB
testcase_06 AC 267 ms
80,888 KB
testcase_07 AC 260 ms
80,900 KB
testcase_08 AC 256 ms
80,908 KB
testcase_09 AC 259 ms
80,988 KB
testcase_10 AC 256 ms
81,024 KB
testcase_11 AC 255 ms
81,044 KB
testcase_12 AC 258 ms
80,944 KB
testcase_13 AC 259 ms
81,136 KB
testcase_14 AC 61 ms
71,304 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# 1 ... g^n + c^n + p^n
# 3 ... 1 - ((g + c)^n + (c + p)^n + (p + g)^n) + g^n + c^n + p^n
MOD = 10 ** 9 + 7
for _ in range(int(input())):
    n, ag, bg, ac, bc, ap, bp = map(int, input().split())
    g = ag * pow(bg, MOD-2, MOD) % MOD
    c = ac * pow(bc, MOD-2, MOD) % MOD
    p = ap * pow(bp, MOD-2, MOD) % MOD
    t1 = sum(pow(x, n, MOD) for x in [g, c, p]) % MOD
    t2 = (1 - sum(pow(x + y, n, MOD) for x, y in [(g, c), (c, p), (p, g)]) + t1) % MOD
    ans = (t1 + t2) % MOD
    print(ans)
0