A random market graph on n assets is built as follows. For every pair of assets i < j, a co-movement score rho_ij is drawn independently and uniformly from [-1, 1]. A filter with threshold theta = p / q is then applied: assets i and j are connected by an edge if and only if |rho_ij| >= theta.
Compute the expected number of connected components of the resulting graph.
One line with the integers n, p and q.
The expected number of connected components, as an exact fraction in lowest terms, written as a/b.
2 <= n <= 30
1 <= p < q <= 1000
In the first sample, n = 2 and theta = 1/2. The single potential edge is present if and only if |rho_12| >= 1/2, which has probability 1 - 1/2 = 1/2. The graph has 1 component when the edge is present and 2 components when it is not, so the expected number of components is 1 * (1/2) + 2 * (1/2) = 3/2.
This is a standard problem: a submission scores full points if it produces the correct output for every test case, and zero otherwise.
2 1 2
3/2
4 1 3
848/729