#C1870. Minimum Operations to Equalize an Array using Bitwise XOR

    ID: 45123 Type: Default 1000ms 256MiB

Minimum Operations to Equalize an Array using Bitwise XOR

Minimum Operations to Equalize an Array using Bitwise XOR

You are given an integer T representing the number of test cases. For each test case, you are given an integer M and an array B of M integers. In one operation, you can perform a bitwise XOR operation in a way that reduces the diversity of array elements. Your task is to determine the minimum number of operations required to make all elements of the array equal.

Note: It turns out that if all elements are already equal, no operation is needed (answer is 0), otherwise the answer is \(M - 1\) where M is the number of elements in the array.

Example:

Input:
1
4
1 2 3 4

Output: 3

</p>

inputFormat

The first line contains an integer T, the number of test cases. Each test case consists of two lines:

  • The first line contains an integer M, the number of elements in the array.
  • The second line contains M space-separated integers representing the elements of the array.

outputFormat

For each test case, output a single line containing the minimum number of operations required to make all the elements equal.

## sample
2
4
1 2 3 4
3
7 7 7
3

0

</p>