library

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

View the Project on GitHub maspypy/library

:warning: other/dyadic_intervals.hpp

Code

// 昇順とは限らない,両端から呼ばれる
template <typename F>
void dyadic_intervals(ll L, ll R, F f) {
  FOR(k, 64) {
    if (L == R) break;
    ll b = 1LL << k;
    if (L & b) f(L, L + b), L += b;
    if (R & b) f(R - b, R), R -= b;
  }
}
#line 1 "other/dyadic_intervals.hpp"
// 昇順とは限らない,両端から呼ばれる
template <typename F>
void dyadic_intervals(ll L, ll R, F f) {
  FOR(k, 64) {
    if (L == R) break;
    ll b = 1LL << k;
    if (L & b) f(L, L + b), L += b;
    if (R & b) f(R - b, R), R -= b;
  }
}
Back to top page