This documentation is automatically generated by online-judge-tools/verification-helper
View the Project on GitHub knshnb/competitive_library
#include "src/Helper/BinarySearch.hpp"
整数の範囲についての二分探索。計算量はO(log |ok - ng|)。
/// @docs src/Helper/BinarySearch.md template <class F> long long binary_search(long long ok, long long ng, F check) { while (std::abs(ok - ng) > 1) { long long mid = (ok + ng) / 2; (check(mid) ? ok : ng) = mid; } return ok; }
#line 1 "src/Helper/BinarySearch.hpp" /// @docs src/Helper/BinarySearch.md template <class F> long long binary_search(long long ok, long long ng, F check) { while (std::abs(ok - ng) > 1) { long long mid = (ok + ng) / 2; (check(mid) ? ok : ng) = mid; } return ok; }