EXPOR  OR
Given an array of N integers A_{1}, A_{2}, A_{3}…A_{N}. If you randomly choose two indexes i ,j such that 1 ≤ i < j ≤ N, what is the expected value of A_{i}  A_{j}?
Input
First line contains an integer T, the number of test cases. Each test case consists of two lines. First line denotes the size of array, N and second line contains N integers forming the array.
1 ≤ T ≤ 10
2 ≤ N ≤ 100,000
0 ≤ Ai < 2^{31}
Output
For each test case, print the answer as an irreducible fraction. Follow the format of the sample output.
The fraction p/q (p and q are integers, and both p ≥ 0 and q > 0 holds) is called irreducible, if there is no such integer d > 1 that divides both p and q separately.
Example
Input: 2 2 0 0 3 1 2 3 Output: 0/1 3/1
hide comments
rajcoolaryan:
20180625 05:42:00
my 50th on spoj


shuvam_kedia:
20180619 03:59:44
Use unsigned long long. 

geeta:
20170525 15:29:05
What is the expected time complexity? My algo is running in O(31*N) and getting TLE. How to optimise it further? 

eightnoteight:
20161029 23:07:44
OMG!!!!!!!


smtcoder:
20160909 23:47:08
After 3 TLEs and 1 WA..Got accepted...


sumitsinghnit:
20160908 13:58:14
Required a lot of optimizations to get AC. Last edit: 20170511 07:30:02 

rayhan50001:
20160906 01:23:43
"f there is no such integer dā>ā1 that divides both p and q separately."


:D:
20160829 21:44:23
bitwise or 

slaski:
20160829 16:44:28
Would be good to define `a  b`. Isn't it binary or? 

:D:
20160829 11:11:27
For the first test case only pair is (0 0) so the result is 00 = 0. For second case we have 3 pairs (1 2) (1 3) (2 3). Or values are 12 = 3, 13 = 3, 23 = 3. So the average is 3. 
Added by:  Evan 
Date:  20160826 
Time limit:  0.5s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: ASM64 GOSU 
Resource:  https://algo.codemarshal.org/contests/goc0101 