题目描述
Alice has an array A of length N. She is interested in finding the number of pairs (i, j) such that 1≤ i < j ≤ N and $A_{i} \oplus A_{j} < A_{i}$ \& A_{j}.
$\oplus$ represents the [Bitwise XOR] operator.
\& represents the [Bitwise AND] operator.
------ Input Format ------
- The first line of input will contain an integer T — number of test cases. Then the test cases follow.
- Each test case contains two lines of input.
- The first line of each test case contains an integer N, the length of the array A.
- The second line of each test case contains $N space-separated integers A_{1}, A_{2}, \ldots , A_{N}$.
------ Output Format ------
For each test case, output the number of pairs (i, j) such that 1 ≤ i < j ≤ N and $A_{i} \oplus A_{j} < A_{i}$ \& A_{j}.
------ Constraints ------
$1 ≤ T ≤ 10^{4}$
$1 ≤ N ≤ 10^{5}$
$1 ≤ A_{i} ≤ 10^{9}$
- Sum of $N$ over all test cases does not exceed $3 \cdot 10^{5}$.
----- Sample Input 1 ------
2
4
1 1 2 3
4
1 2 3 4
----- Sample Output 1 ------
2
1
----- explanation 1 ------
Test case $1$: The two pairs of indices satisfying the condition are $(1, 2)$ and $(3, 4)$, because
- $A_{1} \oplus A_{2} = 0$ and $A_{1} \& A_{2} = 1$
- $A_{3} \oplus A_{4} = 1$ and $A_{3} \& A_{4} = 2$
Test case $2$: The only pair of indices satisfying the condition is $(2, 3)$.
输入格式
见题面
输出格式
见题面