3026: XOR-mean

时间限制:32000 ms 内存限制:128 MB
上传者:
提交:5 通过:4

题目描述

As we all know, the mean of two integers $A$ and $B$ is $\frac{A + B}{2}$.Similarly, let's define XOR-mean of two non-negative integers $A$ and $B$ as $\left \lfloor  \frac{A \bigoplus  B} {2} \right \rfloor$($\bigoplus$ is the XOR operation, $\left \lfloor x \right \rfloor$ is the integer part of $x$).Given an array $C$ of length $n$, count different triples $(i, j, k)$ that satisfy $1 \leq i < j < k \leq n$ and $C[j] = \left \lfloor  \frac{C[i] \bigoplus  C[k]} {2} \right \rfloor$.

输入格式

The first line contains an integer number T, the number of test cases.

For each test case :
The first line contains an integer $n$($1 \leq n \leq 50000$).

The second line contains $n$ integers $C[i]$($0 \leq C[i] \leq 50000$).

输出格式

For each query print the answer.

输入样例 复制

1
10
1 2 3 4 5 6 7 8 9 10

输出样例 复制

23