Count Pairs

3.6

9 votes
Basic Programming, Bit Manipulation, Basics of Bit Manipulation
Problem

Problem:

You are given a sequence of integers of length . Find the number of pairs of indices   for which .

Here,  denotes the bitwise XOR operation.

 Input Format:

  • The first line of the input contains a single integer  - the number of test cases. The description of  test cases follows.
  • The first line of each test case contains a single integer .
  • The second line contains  space-separated integers ​.

Output Format:

  • For each test case print a single integer — the answer to the problem.

Constraints:

  •  for each valid 
  • The sum of  over all test cases does not exceed 
Sample Input
2
2
1 2
3
4 5 9
Sample Output
1
2
Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation
  • Test case : The required pair of indices are .
  • Test case The required pair of indices are and .

 

Editor Image

?