You are given an array $$a$$ of size $$n$$ consisting of integers. Now, you need to find the number of distinct integers x, such that there exists a sequence of distinct indices \(i_1 < i_2 <... < i_m , 1 \le m \le k \) and \(a[i_1] \space or \space a[i_2] \space or \space...\space or \space a_[i_m]=x\)
Here or represents the bitwise OR operator.
Input
First line of the each input will contain two space seperated integers $$n$$ and $$k$$ denoting the size of the array and maximum size of the subset, respectively.
Next line will contain $$n$$ spaced integers denoting elements of the array.
Constraint
\(1 \le n \le 1000\)
\(1 \le k \le 20\)
\(1 \le a[i] \le 2047\)
Output
Output will consists of a single integer denoting the number of unique integers that can be formed by taking Bitwise OR of every subset of size less than or equal to $$k$$.
Array is having 3 integers: 1, 2 and 4.
Subsets having size less than or equal to 2 is $$\{ \{1\} , \{2\} , \{4\} , \{1,2\} , \{1,4\} , \{2,4\} \}$$.
Bitwise OR of the subsets thus obtained is $$\{ 1 , 2 , 4 , 3, 5 , 6 \}$$.
Thus total unique intgers formed by taking bitwise OR of all subsets of size less than or equal to 2 is 6.
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor