結果
問題 |
No.1253 雀見椪
|
ユーザー |
|
提出日時 | 2020-12-26 14:07:56 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,466 ms / 2,000 ms |
コード長 | 571 bytes |
コンパイル時間 | 1,770 ms |
コンパイル使用メモリ | 81,772 KB |
実行使用メモリ | 86,396 KB |
最終ジャッジ日時 | 2024-09-24 17:09:43 |
合計ジャッジ時間 | 17,017 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 14 |
ソースコード
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()) 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)