# 二分查找
def bin_search(li, val):
# 有序列表
low = 0
high = len(li)-1
while low <= high:
mid = (low + high) // 2
if li[mid] == val:
return mid
elif li[mid] > val:
high = mid - 1
else: # li[mid]<val
low = mid + 1
return -1