“As you people have studied probability (SPAS) in 2nd sememster :D “
You have an array of N distinct elements.
Now there are 4 couples. (every couple consist of one male and one female only) .
Lets name couple members as :
couple 1 : M1(male) , F1(female)
couple 2 : M2(male) , F2(female)
couple 3 : M3(male) , F3(female)
couple 4 : M4(male) , F4(female)
Now we will call couples one by one..
1 : couple 1 will come and choose two numbers from array (say a1 and a2) and then they will put those 2 numbers back into array.
2 : couple 2 will come and choose two numbers from array (say b1 and b2) and then they will put those 2 numbers back into array.
3 : couple 3 will come and choose two numbers from array (say c1 and c2) and then they will put those 2 numbers back into array.
4 : couple 4 will come and choose two numbers from array (say d1 and d2) and then they will put those 2 numbers back into array.
It was found that :
a1 > a2
b1 > b2
c1 > c2
d1 < d2
Now find the probabiliy that :
a1 + b1 + c1 + d1 > a2 + b2 + c2 + d2
Input :
First line will contain an integer 'T' (number of test cases ).
For each test case there is an integer 'N' (number of elements in array).
On next line there will b N distinct integers (array elements).
Output :
For each test case find the required probability.
Output the first 6 digits after decimal.
Constraint :
T <= 10
N <=5000
a[i] <=5000
Note : use "double" data type instead of "float"
Problem setter : Mohd Abdullah
test case 1 : probability = .3164000000
output = 316400
test case 2 : probability = .4013254077
output = 401325