Created
January 6, 2020 16:44
-
-
Save SuryaPratapK/0bd480c3ed4b4064615a3411db341152 to your computer and use it in GitHub Desktop.
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
#include <bits/stdc++.h> | |
using namespace std; | |
int main() { | |
//code | |
int tc; | |
cin>>tc; | |
while(tc--) | |
{ | |
int n,k; | |
cin>>n>>k; | |
int i =0; | |
int power = 0; | |
int mask = 1; | |
while(i<k) | |
{ | |
power++; | |
i++; | |
mask<<=1; | |
} | |
if(mask&n) | |
cout<<n<<"\n"; | |
else | |
cout<<(n+pow(2,power))<<"\n"; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment