New binary search method

Правка ru2, от ColobocCodeforces, 2024-12-04 13:38:04

There is new method of binary search which may be exist but I didn't see it.

Instead of using left and right, we can simply add new bit to our answer if it is possible:

while bit > 0:
   if check(ans + bit): 
      ans += bit
   bit /= 2

Constant will be much smaller.

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
ru2 Русский ColobocCodeforces 2024-12-04 13:38:04 21
ru1 Русский ColobocCodeforces 2024-12-04 13:37:13 321 Первая редакция (опубликовано)