luogu#P16340. 「ALFR Round 10」XOR and Simple Trick
「ALFR Round 10」XOR and Simple Trick
Problem Description
Given a sequence of non-negative integers, find the number of pairs of indices such that , and for every and every non-negative integer , the following condition holds: OR .
Input Format
This problem contains multiple test cases. The first line contains a positive integer , representing the number of test cases.
For each test case:
- The first line contains a positive integer .
- The second line contains non-negative integers, where the -th number represents .
Output Format
For each test case, output a single integer representing the answer.
4
5
1 4 5 2 6
7
3 1 4 5 9 2 6
3
114 51 4
6
1 2 4 8 16 32
2
2
1
1
Hint
【Explanation of Sample 1】
For the first test case, the valid pairs are and .
【Constraints】
Let be the sum of over all test cases in a single test file, and be the maximum value of in a single test file.
For all test cases:
- for all
- All are distinct within a single test case.
This problem uses bundled testing. Subtasks are as follows:
| Subtask | Score | ||
|---|---|---|---|
| 1 | |||
| 2 | |||
| 3 | ^ | ||
| 4 | |||
| 5 | |||
| 6 | ^ |