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

binary search (l+r)/2 or (l+r+1)/2 , not a random choice?

Правка en2, от 2020, 2020-04-11 22:15:39

binary search (l+r)/2 or (l+r+1)/2 i saw this on a topcoder article that one or the other will no give while loop but on some test cases both might not as can be seen in submission 76258234 is where i changed (r+l)/2 to r+l+1/2 from this submission 76258059 and my solution passed so how to decide which one will never give a while loop right now i just do it randomly one and if that doesnt pass i do other

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский 2020 2020-04-11 22:15:39 1 Tiny change: ':76258234]is where ' -> ':76258234] is where '
en1 Английский 2020 2020-04-11 22:14:18 492 Initial revision (published)