結果

問題 No.1253 雀見椪
ユーザー flippergoflippergo
提出日時 2020-12-26 14:11:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,051 ms / 2,000 ms
コード長 587 bytes
コンパイル時間 183 ms
コンパイル使用メモリ 81,672 KB
実行使用メモリ 82,068 KB
最終ジャッジ日時 2023-10-24 22:03:58
合計ジャッジ時間 11,751 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
52,264 KB
testcase_01 AC 48 ms
60,340 KB
testcase_02 AC 94 ms
75,528 KB
testcase_03 AC 219 ms
76,104 KB
testcase_04 AC 1,017 ms
79,736 KB
testcase_05 AC 957 ms
79,332 KB
testcase_06 AC 983 ms
82,068 KB
testcase_07 AC 1,051 ms
80,232 KB
testcase_08 AC 970 ms
82,028 KB
testcase_09 AC 1,016 ms
81,256 KB
testcase_10 AC 1,009 ms
81,320 KB
testcase_11 AC 1,032 ms
81,504 KB
testcase_12 AC 958 ms
79,616 KB
testcase_13 AC 935 ms
79,288 KB
testcase_14 AC 48 ms
59,708 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

p = 10**9+7
def pow(x,m):
    if m==0:
        return 1
    if m==1:
        return x
    if m%2==0:
        return (pow(x,m//2)**2)%p
    else:
        return (x*(pow(x,(m-1)//2)**2)%p)%p
T = int(input())
for _ in range(T):
    N,AG,BG,AC,BC,AP,BP = map(int,input().split())
    n = N%(p-1)
    S = 1
    S = (S+2*pow(AG,n)*pow(pow(BG,n),p-2))%p
    S = (S+2*pow(AC,n)*pow(pow(BC,n),p-2))%p
    S = (S+2*pow(AP,n)*pow(pow(BP,n),p-2))%p
    S = (S-pow(BG-AG,n)*pow(pow(BG,n),p-2))%p
    S = (S-pow(BC-AC,n)*pow(pow(BC,n),p-2))%p
    S = (S-pow(BP-AP,n)*pow(pow(BP,n),p-2))%p
    print(S)
0