#P11019. [2016杭电多校]Permutation Bo
[2016杭电多校]Permutation Bo
Permutation Bo
Problem Description
There are two sequences and . is a permutation of . particularly, . We define the expression is 1 when is True,is 0 when is False. Define the function $f(h)=\sum_{i=1}^{n}{c_i[h_i>h_{i-1}~~and~~h_i>h_{i+1}]}$ Bo have gotten the value of , and he wants to know the expected value of .
Input
This problem has multi test cases(no more than ). For each test case, the first line contains a non-negative integer , second line contains non-negative integer .
Output
For each test cases print a decimal - the expectation of . If the absolute error between your answer and the standard answer is no more than , your solution will be accepted.
Sample Input
4
3 2 4 5
5
3 5 99 32 12
Sample Output
6.000000
52.833333
Author
绍兴一中
Source
2016 Multi-University Training Contest 3