結果

問題 No.1253 雀見椪
ユーザー aqua_tenhouaqua_tenhou
提出日時 2020-10-09 22:59:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 304 ms / 2,000 ms
コード長 507 bytes
コンパイル時間 831 ms
コンパイル使用メモリ 86,840 KB
実行使用メモリ 79,452 KB
最終ジャッジ日時 2023-09-27 19:12:52
合計ジャッジ時間 4,835 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
70,956 KB
testcase_01 AC 68 ms
71,332 KB
testcase_02 AC 69 ms
71,116 KB
testcase_03 AC 103 ms
76,152 KB
testcase_04 AC 295 ms
79,232 KB
testcase_05 AC 301 ms
79,312 KB
testcase_06 AC 296 ms
79,212 KB
testcase_07 AC 295 ms
79,304 KB
testcase_08 AC 301 ms
79,212 KB
testcase_09 AC 304 ms
79,228 KB
testcase_10 AC 295 ms
79,300 KB
testcase_11 AC 294 ms
79,180 KB
testcase_12 AC 291 ms
79,452 KB
testcase_13 AC 294 ms
79,268 KB
testcase_14 AC 66 ms
71,276 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

t = int(input())
mod = 10**9 + 7
for i in range(t):
    N,Ag,Bg,Ac,Bc,Ap,Bp = map(int,input().split())

    p1 = pow( Ag*pow(Bg,mod-2,mod) + Ac*pow(Bc,mod-2,mod), N, mod )
    p2 = pow( Ac*pow(Bc,mod-2,mod) + Ap*pow(Bp,mod-2,mod), N, mod )
    p3 = pow( Ap*pow(Bp,mod-2,mod) + Ag*pow(Bg,mod-2,mod), N, mod )
    
    p4 = pow( Ag*pow(Bg,mod-2,mod), N, mod )
    p5 = pow( Ac*pow(Bc,mod-2,mod), N, mod )
    p6 = pow( Ap*pow(Bp,mod-2,mod), N, mod )

    ans = 1 - (p1+p2+p3) + 2*(p4+p5+p6)
    print(ans%mod)
0