We are given an array arr of $n$ element. We need to count number of non-empty subsequences such that these individual subsequences have same values of bitwise AND, OR and XOR. For example, we need to count a subsequence (x, y, z) if (x | y | z) is equal to (x & y & z) and (x ^ y ^ z). For a single element subsequence, we consider the element itself as result of XOR, AND and OR. Therefore all single element subsequences are always counted as part of result.
The editorial for the above problem states:
- If there are $n$ occurrences of zeroes in the given array, then will be $2^{n} - 1$ subsequences contributed by these zeroes.
- If there are $n$ occurrences of a non-zero element $x$, then there will be $2^{n-1}$ subsequences contributed by occurrences of this element. Please note that, in case of non-zero elements, only odd number of occurrences can cause same results for bitwise operators.
I am not able to understand the proof for the statement Please note that, in case of non-zero elements, only odd number of occurrences can cause same results for bitwise operators.
Can anyone help me understanding why this works?