|
||||||||||
HarmonyTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 222 Accepted Submission(s): 32 Special Judge Problem Description Ali is given an array, which is a permutation of {1, 2, 3 ... , n}. He thinks that only the increasing sequence is harmony, so he wants to change the sequence into a harmony one. But the only operation he can use is: Choosing a contiguous subsequence {A[i], A[i + 1]...A[j]} and do a random shuffling on it. (Random shuffle means that every permutation will appear with equal possibility) So, what¡¯s the expected number of operations when using the best strategy? Input The input consists several testcases. First line, an integer N (0 < N <= 50) denoting the length of this array. In the next line there are N integers, representing a permutation. Output Print one line with the expectation. The result should be given with absolute or relative error of at most 10-6. Sample Input
Sample Output
Source | ||||||||||
|