Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

1 line binary search in c++20

Правка en1, от Xylenox, 2024-10-05 15:12:42
auto res = *ranges::partition_point(views::iota(lo, hi), check);

this returns the first $$$x$$$ in the range $$$[lo, hi)$$$ such that check(x) is not true, or $$$hi$$$ if it doesn't exist. Be careful to make sure the $$$lo$$$ and $$$hi$$$ are both integers of the same type, otherwise there is weird behavior.

example usage: 284450329

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский Xylenox 2024-10-05 15:12:42 377 Initial revision (published)