提交记录 21527
提交时间 |
评测时间 |
2024-04-12 11:32:31 |
2024-04-12 11:32:35 |
int binary_search(const unsigned *a, int n, unsigned x)
{
static int ans=-1,nx;
register unsigned l=0,r=n-1,mid;
if(ans!=-1)
{
if(x==nx)return ans;
if(x<nx)r=ans-1;
else l=ans+1;
}
while(l<=r)
{
mid=(l+r)>>1;
if(a[mid]==x)
{
nx=x;
return ans=mid;
}
if(a[mid]<x)
{
l=mid+1;
}
else
{
r=mid-1;
}
}
return l;
}
Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
Testcase #1 | 503.96 us | 12 KB | Accepted | Score: 100 | 显示更多 |
Judge Duck Online | 评测鸭在线
Server Time: 2024-05-19 01:40:46 | Loaded in 0 ms | Server Status
个人娱乐项目,仅供学习交流使用