Advertisement
nq1s788

Бинарный поиск

May 16th, 2024
688
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.12 KB | None | 0 0
  1. l = 0
  2. r = n - 1
  3. while r - l > 1:
  4.     m = (l + r) // 2
  5.     if a[m] == 1:
  6.         r = m
  7.     else:
  8.         l = m
  9.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement