Bob and K - Subset
Practice
3.6 (16 votes)
Basic programming
Basics of implementation
Hash maps
Implementation
Medium
Problem
56% Success 8262 Attempts 30 Points 2s Time Limit 256MB Memory 1024 KB Max Code

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$$.

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

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
82 votes
Tags:
Medium
Points:30
9 votes
Tags:
Mediumad hocapproved
Points:30
3 votes
Tags:
Basic ProgrammingBasics of ImplementationHash MapsImplementationMedium