eolymp
bolt
Try our new interface for solving problems
Problems

Reset the significant bits

published at 2/12/24, 2:26:34 pm

include <bits/stdc++.h>

using namespace std;

typedef long long ll; typedef long double ld;

void solve() {

int n,k;
cin >> n >> k;
int ans = (1<<k-1);

cout << (n&ans) << '\n';

}

int main() { iosbase::syncwith_stdio(false), cin.tie(NULL), cout.tie(NULL); solve();

return 0;

}

published at 2/16/24, 7:18:34 am

include <bits/stdc++.h>

using namespace std; int main () { int k,n,ans; cin>>n>>k; n&=(1<<k)-1; cout<<n; }