algorithm

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

View the Project on GitHub gtnao/algorithm

:warning: src/search/real_binary_search.hpp

Code

#pragma once

#include <bits/stdc++.h>
using namespace std;

template <typename T>
T real_bin_search(T ng, T ok, function<bool(T)> is_ok, int loop = 100) {
  for (int i = 0; i < loop; i++) {
    T mid = (ok + ng) / 2;

    if (is_ok(mid)) {
      ok = mid;
    } else {
      ng = mid;
    }
  }
  return ok;
}
#line 2 "src/search/real_binary_search.hpp"

#include <bits/stdc++.h>
using namespace std;

template <typename T>
T real_bin_search(T ng, T ok, function<bool(T)> is_ok, int loop = 100) {
  for (int i = 0; i < loop; i++) {
    T mid = (ok + ng) / 2;

    if (is_ok(mid)) {
      ok = mid;
    } else {
      ng = mid;
    }
  }
  return ok;
}
Back to top page