結果

問題 No.1253 雀見椪
ユーザー shotoyooshotoyoo
提出日時 2020-10-09 22:18:20
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 281 ms / 2,000 ms
コード長 540 bytes
コンパイル時間 228 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 76,672 KB
最終ジャッジ日時 2024-07-20 12:17:27
合計ジャッジ時間 3,954 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


t = int(input())
for _ in range(t):
    n,a0,b0,a1,b1,a2,b2 = list(map(int, input().split()))
    a = [a0,a1,a2]
    b = [b0,b1,b2]
    ans = 0
    M = 10**9+7
    for i in range(3):
        ans += 2* pow(a[i], n, M) * pow(pow(b[i], M-2, M), n, M)
        ans %= M
    ans += 1
    for i in range(3):
        ans -= pow((b[i]-a[i]), n, M) * pow(pow(b[i], M-2, M), n, M)
    ans %= M
    print(ans)
0