結果

問題 No.1253 雀見椪
ユーザー uni_pythonuni_python
提出日時 2020-10-09 23:40:24
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 214 ms / 2,000 ms
コード長 944 bytes
コンパイル時間 244 ms
コンパイル使用メモリ 87,168 KB
実行使用メモリ 77,432 KB
最終ジャッジ日時 2023-09-27 20:00:30
合計ジャッジ時間 3,946 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
70,852 KB
testcase_01 AC 69 ms
71,124 KB
testcase_02 AC 70 ms
71,196 KB
testcase_03 AC 87 ms
75,908 KB
testcase_04 AC 214 ms
77,396 KB
testcase_05 AC 204 ms
77,256 KB
testcase_06 AC 205 ms
77,428 KB
testcase_07 AC 207 ms
77,216 KB
testcase_08 AC 201 ms
77,320 KB
testcase_09 AC 201 ms
77,168 KB
testcase_10 AC 200 ms
77,328 KB
testcase_11 AC 208 ms
77,076 KB
testcase_12 AC 198 ms
77,432 KB
testcase_13 AC 201 ms
77,256 KB
testcase_14 AC 68 ms
71,328 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=sys.stdin.readline
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    T=I()
    

    for _ in range(T):
        L=LI()
        N=L[0]
        N3=N*(N-1)*(N-2)#3人とってきて,g,c,pを割り当てる
        N3%=mod
        
        g=(L[1]*pow(L[2],mod-2,mod))%mod
        c=(L[3]*pow(L[4],mod-2,mod))%mod
        p=(L[5]*pow(L[6],mod-2,mod))%mod
        
        ng=c+p
        nc=g+p
        np=g+c
        
        gg=pow(ng,N,mod)#誰もぐーを出さない
        cc=pow(nc,N,mod)
        pp=pow(np,N,mod)
        
        ggg=pow(g,N,mod)#全員ぐー
        ccc=pow(c,N,mod)
        ppp=pow(p,N,mod)
        
        
        ans=1-(gg+cc+pp)+2*(ggg+ccc+ppp)
        ans%=mod
        print(ans)
        
        
        # print((gg,cc,pp))
        # print((ggg,ccc,ppp))
        
        
        


main()
0