We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e376510 commit 4a4d768Copy full SHA for 4a4d768
cp-algo/util/bit.hpp
@@ -13,7 +13,7 @@ namespace cp_algo {
13
return (1ULL << n) - 1;
14
}
15
size_t order_of_bit(auto x, size_t k) {
16
- return std::popcount(x << ( -k % bit_width<decltype(x)>));
+ return k ? std::popcount(x << (bit_width<decltype(x)> - k)) : 0;
17
18
[[gnu::target("bmi2")]] inline size_t kth_set_bit(uint64_t x, size_t k) {
19
return std::countr_zero(_pdep_u64(1ULL << k, x));
0 commit comments