Given an array A with N integers between 3500 and 4500, find the number of unique multisets that can be formed using elements from the array such that the bitwise XOR of all the elements of the multiset is a prime number.
Solution
First, we notice that 3500 ≤ a[i] ≤ 4500. So the bitwise XOR of any multiset is in the range [0,(2^13)-1].
Let count[i] be the number of i in array A. Let f[i,j] be the number of unique multisets whose elements are within [3500,i], and whose XOR equals to j. So we have