icpc-snippet

This documentation is automatically generated by online-judge-tools/verification-helper

View the Project on GitHub EarthMessenger/icpc-snippet

:heavy_check_mark: Bit Manipulation
(lib/misc/bitop.hpp)

Depends on

Required by

Verified with

Code

/**
 * @brief Bit Manipulation
 */
#pragma once
#include "lib/internal.hpp"

int clz(u64 x) { return __builtin_clzll(x); }
int ctz(u64 x) { return __builtin_ctzll(x); }
// floor(log2(x))
int lg2(u64 x) { return 63 ^ clz(x); }
// bit width
int btw(u64 x) { return lg2(x) + 1; }
// bit ceil
u64 btc(u64 x) { return (x <= 1 ? 1 : 1ull << btw(x - 1)); }
// bit floor
u64 btf(u64 x) { return 1ull << lg2(x); }
// popcount
__attribute__((target("popcnt"))) int ppc(u64 x)
{
  return __builtin_popcountll(x);
}
Traceback (most recent call last):
  File "/home/runner/.local/lib/python3.10/site-packages/onlinejudge_verify/documentation/build.py", line 71, in _render_source_code_stat
    bundled_code = language.bundle(stat.path, basedir=basedir, options={'include_paths': [basedir]}).decode()
  File "/home/runner/.local/lib/python3.10/site-packages/onlinejudge_verify/languages/cplusplus.py", line 187, in bundle
    bundler.update(path)
  File "/home/runner/.local/lib/python3.10/site-packages/onlinejudge_verify/languages/cplusplus_bundle.py", line 312, in update
    raise BundleErrorAt(path, i + 1, "#pragma once found in a non-first line")
onlinejudge_verify.languages.cplusplus_bundle.BundleErrorAt: lib/misc/bitop.hpp: line 4: #pragma once found in a non-first line
Back to top page