提交记录 20370


用户 题目 状态 得分 用时 内存 语言 代码长度
c20150005 1003. 测测你的二分查找 Accepted 100 421.5 us 12 KB C++14 525 B
提交时间 评测时间
2023-10-13 21:11:32 2023-10-13 21:11:35
#include<stdlib.h>
int binary_search(const unsigned *a, int n, unsigned x)
{unsigned l=614514,r=n-614751,mid;unsigned long long X=x;
srand(534);
while(l<=r){
mid=/*(r*(X-a[l])+l*(a[r]-X))/(a[r]-a[l])*/l+rand()%(r-l+1);
if(a[mid]==x){
return mid;
}if(a[mid]<x)l=mid+1;
else r=mid-1;
}/* 
if(a[l]==x)return l;
if(a[l+1]==x)return l+1;
if(a[l+2]==x)return l+2;
if(a[l+3]==x)return l+3;
if(a[l+4]==x)return l+4;
if(a[l+5]==x)return l+5;
if(a[l+6]==x)return l+6;
if(a[l+7]==x)return l+7;
if(a[l+8]==x)return l+8; 
return l+9;*/ 
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #1421.5 us12 KBAcceptedScore: 100


Judge Duck Online | 评测鸭在线
Server Time: 2025-09-13 09:37:08 | Loaded in 0 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠