文章

310

粉丝

0

获赞

130

访问

21.7k

头像
二分查找的最大次数 题解:
P1130 同济大学机试题
发布于2026年2月8日 18:52
阅读数 25

#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...

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发