二分法
arr = range(10000000)
start = 0
end = len(arr)-1
res = 776575
count = 0
print arr.index(res)
while True:
    count = count+1
    mid = (start+end)/2
    if arr[mid]>res:
        end = mid
    elif arr[mid]<res:
        start = mid
    else:
        print mid
        break

print count

相关文章:

  • 2021-04-25
  • 2021-09-07
  • 2021-09-18
  • 2022-01-29
  • 2021-05-26
猜你喜欢
  • 2021-12-03
  • 2021-06-09
  • 2022-12-23
  • 2022-12-23
  • 2021-11-30
  • 2021-06-08
  • 2021-08-20
相关资源
相似解决方案