結果

問題 No.1253 雀見椪
ユーザー flippergo
提出日時 2020-12-26 14:15:23
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 854 ms / 2,000 ms
コード長 593 bytes
コンパイル時間 280 ms
コンパイル使用メモリ 82,092 KB
実行使用メモリ 81,320 KB
最終ジャッジ日時 2024-09-24 17:15:33
合計ジャッジ時間 9,388 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

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
    a = pow(BG,n)
    b = pow(BC,n)
    c = pow(BP,n)
    S = (S+2*pow(AG,n)*pow(a,p-2))%p
    S = (S+2*pow(AC,n)*pow(b,p-2))%p
    S = (S+2*pow(AP,n)*pow(c,p-2))%p
    S = (S-pow(BG-AG,n)*pow(a,p-2))%p
    S = (S-pow(BC-AC,n)*pow(b,p-2))%p
    S = (S-pow(BP-AP,n)*pow(c,p-2))%p
    print(S)
0