Logo
(追記) (追記ここまで)

25929번 - Squaring the Triangle 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
5 초 256 MB131312100.000%

문제

Wesley creates a graph $G$ that contains $N$ vertices. For each pair of vertices $\{u, v\},ドル there is a probability of $\dfrac{p}{q}$ that an edge exists between $u$ and $v$. The probabilities are independent of each other.

Let $∆(G)$ denote the number of triangles in $G$. A triangle is a set of 3ドル$ vertices that are connected by 3ドル$ edges.

Please help Wesley find the expected value of $(∆(G))^2$.

입력

Line 1ドル$ contains integer $T$ (1ドル ≤ T ≤ 10^6$), the number of cases. $T$ lines follow. The $i$th line contains integers $N,ドル $p,ドル $q$ (3ドル ≤ N ≤ 10^6,ドル 1ドル ≤ p < q ≤ 10^6$), separated by spaces.

출력

Output $T$ lines, one line for each case. Suppose the answer to the $i$th case is $\dfrac{P}{Q},ドル in lowest terms. Output $PQ^{-1} \pmod {10^9 + 7}$. That is, output a number $R$ such that 0ドル ≤ R < 10^9 + 7$ and $P ≡ RQ \pmod {10^9 + 7}$.

제한

예제 입력 1

2
3 50 100
7 8 9

예제 출력 1

125000001
655855196

힌트

출처

Contest > Waterloo's local Programming Contests > 2022 Waterloo Fall Local C번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /