Skip to content

Instantly share code, notes, and snippets.

@SuryaPratapK
Created January 6, 2020 16:44
Show Gist options
  • Save SuryaPratapK/0bd480c3ed4b4064615a3411db341152 to your computer and use it in GitHub Desktop.
Save SuryaPratapK/0bd480c3ed4b4064615a3411db341152 to your computer and use it in GitHub Desktop.
#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