Compute the minimum expected number of random subset shuffles that sorts a permutation of 1 to N into increasing order.
Hard8ProbabilityCombinatoricsMathNo attempts yetTime limit5sMemory limit512 MBHere is a man who sorts in a very unusual way.
And his name is John Cena!!!!

John Cena is no algorithm expert, so he sorts numbers his own way. The array he sorts holds each natural number from 1 to N exactly once. First he picks a few elements of the array and shouts "You can't see me". Then he hits every picked element with a Five Knuckle Shuffle at the same time. The picked elements take heavy damage and their order becomes random: if he picked k elements, all k! arrangements of those elements over those k positions come out with equal probability.
Before each shuffle John Cena looks at the current array and then decides what to pick next. He wants to minimize the expected number of Five Knuckle Shuffles needed until the array is sorted in increasing order. Shuffles thrown at the same time count as one. Find that minimum expected value.
The first line has the number of test cases T. Each test case takes two lines. The first line has the length of the array N, and the second line has the elements of the array in order.
1≤T≤100 and 1≤N≤10. The array holds each natural number from 1 to N exactly once.
For each test case print one line in the form Case #x: y, where x is the test case number and y is the minimum expected value. Print y rounded to six digits after the decimal point.
In case #1 of the first example John Cena picks both elements. With probability 1/2 the array becomes sorted and with probability 1/2 it stays as it is, so the expected value is 2.
In case #2 he picks 3 and 2. For the same reason as case #1 the expected value is 2.
In case #3 he picks 2 and 1, then picks 4 and 3. Each of the two costs 2 in expectation, so the total is 4.