atcoder#ABC194D. [ABC194D] Journey
[ABC194D] Journey
Score : points
Problem Statement
We have a graph with vertices called Vertex through . Takahashi is standing on Vertex . The graph has no edges now. Takahashi will repeatedly do the following operation:
- Choose one of the vertices (including the one on which Takahashi is standing now). Every vertex is chosen with probability , independently from previous operations.
- Add an edge between the vertex on which Takahashi is standing now and the chosen vertex, and go to the chosen vertex.
Find the expected value of the number of times he does the operation until the graph becomes connected.
Constraints
Input
Input is given from Standard Input in the following format:
Output
Print the answer. Your answer will be considered correct when its absolute or relative error from our answer is at most .
2
2.00000000000
The graph becomes connected when the operation chooses Vertex for the first time. By considering the case Vertex is chosen for the first time in the -th operation for each , the answer is $\sum_{i = 1}^{\infty} (i \times (\frac{1}{2})^i) = 2$.
3
4.50000000000