forked from iiitv/ChefLib
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Manish Kumar
authored
Oct 2, 2017
1 parent
b003d56
commit d70dfa1
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
//Only if a number is power of 2 and is not present, it is required to add. | ||
//Make a pattern till 12-13 and you will realize you can make all | ||
//numbers from taking bitwise or of some of numbers other than power of 2s | ||
|
||
//code copyright: Manish Kumar, E&C, IIT Roorkee | ||
#include <iostream> | ||
#include <cmath> | ||
#include <climits> | ||
#include <cstring> | ||
#include <vector> | ||
#include <map> | ||
using namespace std; | ||
#define si(n) scanf("%d",&n) | ||
#define mem(A,i) memset(A, i, sizeof(A)) | ||
#define rep(i, start, end) for(int i=start; i<end; i++) | ||
#define repDown(i, start, end) for(ll i=start; i>=end; i--) | ||
|
||
bool powerof2(int x){ | ||
return x && (!(x&(x-1))); | ||
} | ||
|
||
int n,k; | ||
int arr[100005]; | ||
#define sz 1<<21 | ||
|
||
int main(){ | ||
int t=1; | ||
si(t); | ||
while(t--){ | ||
si(n); | ||
si(k); | ||
rep(i,0,n) si(arr[i]); | ||
bool present[10+(1<<k)]; | ||
mem(present,false); | ||
rep(i,0,n) present[arr[i]]=true; | ||
int ans=0; | ||
rep(i,1,1<<k) if(powerof2(i) && present[i]==false) ans++; | ||
cout << ans << endl; | ||
} | ||
return 0; | ||
} |