結果

問題 No.1253 雀見椪
ユーザー anagohirameanagohirame
提出日時 2020-10-09 22:55:07
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 199 ms / 2,000 ms
コード長 492 bytes
コンパイル時間 274 ms
コンパイル使用メモリ 87,012 KB
実行使用メモリ 78,776 KB
最終ジャッジ日時 2023-09-27 18:59:17
合計ジャッジ時間 3,641 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 61 ms
71,220 KB
testcase_01 AC 61 ms
71,344 KB
testcase_02 AC 63 ms
71,024 KB
testcase_03 AC 77 ms
75,288 KB
testcase_04 AC 194 ms
78,776 KB
testcase_05 AC 193 ms
78,504 KB
testcase_06 AC 193 ms
78,612 KB
testcase_07 AC 199 ms
78,608 KB
testcase_08 AC 194 ms
78,596 KB
testcase_09 AC 195 ms
78,560 KB
testcase_10 AC 193 ms
78,544 KB
testcase_11 AC 190 ms
78,308 KB
testcase_12 AC 192 ms
78,556 KB
testcase_13 AC 197 ms
78,756 KB
testcase_14 AC 64 ms
71,152 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
def input():
	return sys.stdin.buffer.readline()[:-1]

MOD = 10**9+7

def f(n, a1, b1, a2, b2, a3, b3):
	g = (a1 * pow(b1, MOD-2, MOD)) % MOD
	c = (a2 * pow(b2, MOD-2, MOD)) % MOD
	p = (a3 * pow(b3, MOD-2, MOD)) % MOD
	res = 1
	res += 2 * (pow(g, n, MOD) + pow(c, n, MOD) + pow(p, n, MOD))
	res -= pow(g+c, n, MOD) + pow(c+p, n, MOD) + pow(p+g, n, MOD)
	return res % MOD

for _ in range(int(input())):
	n, p, q, r, s, t, u = map(int, input().split())
	print(f(n, p, q, r, s, t, u))
0