library

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

View the Project on GitHub maspypy/library

:warning: other/exp_search.hpp

Code

// find max true
template <typename F>
ll exp_search(F check, ll ok) {
  ll d = 1;
  while (check(ok + d)) {
    ok += d;
    d += d;
  }
  ll ng = ok + d;
  while (ok + 1 < ng) {
    ll x = (ok + ng) / 2;
    (check(x) ? ok : ng) = x;
  }
  return ok;
}
#line 1 "other/exp_search.hpp"
// find max true
template <typename F>
ll exp_search(F check, ll ok) {
  ll d = 1;
  while (check(ok + d)) {
    ok += d;
    d += d;
  }
  ll ng = ok + d;
  while (ok + 1 < ng) {
    ll x = (ok + ng) / 2;
    (check(x) ? ok : ng) = x;
  }
  return ok;
}
Back to top page