#P1943. Expected Number of Local Maxima in a Permutation
Expected Number of Local Maxima in a Permutation
Expected Number of Local Maxima in a Permutation
Given a permutation of n distinct numbers, we define a local maximum as an element that is larger than all the numbers preceding it. Since the first element has no preceding numbers, it is trivially a local maximum.
In a randomly generated permutation of length n, the expected number of local maxima is given by:
\( E = \sum_{i=1}^{n} \frac{1}{i} \)
Your task is to compute this expected value and output it with six decimal places of precision.
inputFormat
The input consists of a single integer n (1 ≤ n ≤ 106), representing the length of the permutation.
outputFormat
Output the expected number of local maxima in the permutation, formatted to six decimal places.
sample
1
1.000000