二分查找的最大次数 题解:
#include<bits/stdc++.h>
using namespace std;
int fun(int n,int pos)
{
int count=0;
int ll=0;
int rr=n-1;
while(1)
{
count++;
int mid=(ll+rr)/2;
if(mid==pos)
{
return count;
}
else if(mid>pos)
{
rr=mid;
}
else
{
ll=mid+1;
}
}
return count;
&n...
登录后发布评论
暂无评论,来抢沙发