## 3-idiots

原题：http://acm.hdu.edu.cn/showproblem.php?pid=4609

Problem Description

King OMeGa catched three men who had been streaking in the street. Looking as idiots though, the three men insisted that it was a kind of performance art, and begged the king to free them. Out of hatred to the real idiots, the king wanted to check if they were lying. The three men were sent to the king's forest, and each of them was asked to pick a branch one after another. If the three branches they bring back can form a triangle, their math ability would save them. Otherwise, they would be sent into jail.

However, the three men were exactly idiots, and what they would do is only to pick the branches randomly. Certainly, they couldn't pick the same branch - but the one with the same length as another is available. Given the lengths of all branches in the forest, determine the probability that they would be saved.

Input

An integer T(T≤100) will exist in the first line of input, indicating the number of test cases.

Each test case begins with the number of branches N(3≤N≤105).

The following line contains N integers a_i (1≤a_i≤105), which denotes the length of each branch, respectively.

Output

Output the probability that their branches can form a triangle, in accuracy of 7 decimal places.

Sample Input

2

4

1 3 3 4

4

2 3 3 4

Sample Output

0.5000000

1.0000000

题目大意：

给出n条线段的长度，求随机选择3条线段，这3条线段可以组成三角形的概率。

个人解法：

处理出凑成2条**不同线段**和为x的方案数。

接下来我们枚举每一条线段，计算出和小于当前线段的所有组合的数量。这是不合法的方案。（计算合法的方案似乎去重有点麻烦）

拿总的方案减去即可得到合法的方案。即可得到答案。

对于处理出凑成2条**不同线段**和为x的方案数，我们尝试使用FFT。

处理出桶，那这个桶当成一个多项式，自己与自己的卷积就可以得到组合。不过计算了 一些重复的：

和为偶数的，多计算了一次自己与自己组合

处理完上面的之后，得到的是排列的个数。如果要拿到组合的个数就还需要/2。

如果是相同线段就要另当别论了。

代码如下：

（HDU不让用M_PI，然后只好手写……）