#P1943. Local Maxima

Local Maxima

Description

Given a permutation. If an element is larger than all the elements before it, it is called a "Local Maxima".

Now, in a randomly generated permutation of length nn, find the expected number of elements that are "Local Maxima".

Input Format

A single line containing a positive integer nn.

Output Format

Output a single real number representing the answer, rounded to eight decimal places.

2
1.50000000

Hint

There are 22 permutations of length 22: (1,2)(1, 2) and (2,1)(2, 1). In the former, both numbers are "Local Maxima"; in the latter, only the first number 22 is a "Local Maxima".

Constraints

  • For 30%30\% of the testdata, n10n \leq 10.
  • For 80%80\% of the testdata, n106n \leq 10^6.
  • For 100%100\% of the testdata, 1n<2311 \leq n < 2^{31}.

Translated by ChatGPT 5