Commit 7473d795 by BellCodeEditor

save project

parent ecfc7455
Showing with 14 additions and 12 deletions
...@@ -2,15 +2,17 @@ ...@@ -2,15 +2,17 @@
num_list = [1, 3, 5, 8, 11, 15, 17, 18, 20, 21] num_list = [1, 3, 5, 8, 11, 15, 17, 18, 20, 21]
num=17 num=17
low=0 low=0
high=len(num_list)-1 def cnm(num_list,num):
while low <= high: high=len(num_list)-1
mid=(low+high)//2 while low <= high:
guess=num_list[mid] mid=(low+high)//2
if num==guess: guess=num_list[mid]
print("李宣邑别奖励自己了,你的困八都弯了",mid) if num==guess:
break print("李宣邑别奖励自己了,你的困八都弯了",mid)
elif guess < num: return mid
low = mid + 1 elif guess < num:
else: low = mid + 1
high = mid -1 else:
high = mid -1
return "入木几"
print(cnm(num_list_1,num_1))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment