#P7474. Idea Exchange and Competition Connectivity

    ID: 20669 Type: Default 1000ms 256MiB

Idea Exchange and Competition Connectivity

Idea Exchange and Competition Connectivity

There are n children, each with a unique idea numbered from \(1\) to \(n\). For each child \(i\), the teacher has a deck of cards numbered \(1,2,\dots,n\). The child randomly draws one card. If the card’s number equals \(i\), the child still keeps the drawn card (recording the draw) and draws again; this process repeats until the drawn card has a number different from \(i\). Once a child draws a card with a number different from his/her own, the child and the child whose number is on the card exchange ideas (i.e. they share all the ideas that they know so far). After every child has drawn at least once, each child organizes a contest featuring all the ideas collected from the exchanges. Two contests are said to be connected if they share at least one common idea; this relation is transitive (i.e. if contest A is connected to contest B and contest B is connected to contest C, then contest A is connected to contest C). Hence, all connected contests form a competition set.

In other words, for each vertex \(i\) (child) we draw an undirected edge from \(i\) to a vertex chosen uniformly from \([1,n]\). If the drawn vertex is \(i\) (a self‐loop) we still count that edge and then draw another edge until an edge connecting to a different vertex is drawn. This yields exactly one non‐self edge per vertex, while self–loops may be drawn additionally. The exchange of ideas happens along the non–self edges, and a connected component (contest set) is formed by taking the transitive closure of these edges.

Your task is to compute two expected values given the number \(n\):

  • \(E_0\): the expected total number of card draws among all children. (Each child draws until a different number appears; note that the expected draws for one child is \(\frac{1}{(n-1)/n}=\frac{n}{n-1}\), so \(E_0=n\cdot\frac{n}{n-1}=\frac{n^2}{n-1}\). )
  • \(E_1\): the expected number of connected components (i.e. competition sets) formed by the non–self edges. Note that the non–self edges form a random mapping \(f:\{1,2,\dots,n\}\to\{1,2,\dots,n\}\) with \(f(i)\neq i\) for all \(i\). It can be shown that the expected number of connected components is
    \[ E_1 \;=\; \sum_{k=2}^{n} \frac{1}{n-1)^k}\cdot \frac{n!}{(n-k)!\, k} \quad \text{,} \] which, for example, gives \(E_1=1\) when \(n=2\) and \(E_1\approx1.037037\) when \(n=4\).

Input: A single integer \(n\) (\(n\ge2\)).

Output: Two real numbers \(E_0\) and \(E_1\) separated by a space. Print your answers with 6 decimal places.

inputFormat

The input consists of a single integer \(n\) (\(n\ge2\)).

outputFormat

Output two real numbers: the expected total number of card draws \(E_0\) and the expected number of competition sets \(E_1\), separated by a space. Both answers should be printed to 6 decimal places.

sample

2
4.000000 1.000000