Squaring the Triangle
Time limit5sMemory limit256 MB
Given N vertices and edge probability p/q, find the expected square of the triangle count in a random graph, modulo 1e9+7, for T queries.
- Level
Medium6 of 10
- Topics
- Math, Combinatorics, Probability, Number theory
- Solved
- No attempts yet
Problem
Wesley creates a graph with vertices. For each pair of vertices , an edge exists between and with probability . The probabilities are independent of each other.
Let denote the number of triangles in . A triangle is a set of 3 vertices connected by 3 edges.
Find the expected value of .
Input
The first line contains an integer (), the number of cases. The next lines each contain integers , , (, ), separated by spaces.
Output
Output lines, one for each case. If the expected value for a case is in lowest terms, output . That is, output an integer with such that .