Skip to content

Commit

Permalink
Add 01052.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiyabye committed Jan 20, 2024
1 parent d55f086 commit 16d7447
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions 01xxx/01052.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include <iostream>
using namespace std;

void solve(void) {
int n, k; cin >> n >> k;

int ans = 0;
while (__builtin_popcount(n) > k) {
int x = n & -n;
n += x; ans += x;
}
cout << ans;
}

int main(void) {
ios::sync_with_stdio(false);
cin.tie(nullptr); cout.tie(nullptr);

solve();
return 0;
}

0 comments on commit 16d7447

Please sign in to comment.