아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Squaring the Triangle

시간 제한5초메모리 제한256 MB

요약
각 간선이 독립적으로 확률 p/q로 존재하는 N개 정점의 무작위 그래프에서 삼각형 개수의 제곱의 기댓값을 1e9+7로 나눈 나머지를 구한다.
난이도

보통10점 중 7점

유형
조합론, 확률, 수학, 정수론
정답자
아직 제출이 없습니다

문제

Wesley creates a graph GG that contains NN vertices. For each pair of vertices u,v\\{u, v\\}, there is a probability of pq\dfrac{p}{q} that an edge exists between uu and vv. The probabilities are independent of each other.

Let ∆(G)∆(G) denote the number of triangles in GG. A triangle is a set of 33 vertices that are connected by 33 edges.

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

입력

Line 11 contains integer TT (1≤T≤1061 ≤ T ≤ 10^6), the number of cases. TT lines follow. The iith line contains integers NN, pp, qq (3≤N≤1063 ≤ N ≤ 10^6, 1≤p<q≤1061 ≤ p < q ≤ 10^6), separated by spaces.

출력

Output TT lines, one line for each case. Suppose the answer to the iith case is PQ\dfrac{P}{Q}, in lowest terms. Output PQ−1(mod109+7)PQ^{-1} \pmod {10^9 + 7}. That is, output a number RR such that 0≤R<109+70 ≤ R < 10^9 + 7 and P≡RQ(mod109+7)P ≡ RQ \pmod {10^9 + 7}.

예제1

  1. 예제 1

    입력
    2
    3 50 100
    7 8 9
    
    예상 출력
    125000001
    655855196