提交记录 2012


用户 题目 状态 得分 用时 内存 语言 代码长度
lastans7 1003. 测测你的二分查找 Accepted 100 78.48 us 12 KB C 371 B
提交时间 评测时间
2018-06-21 15:27:34 2020-07-31 20:57:35
int binary_search(const unsigned *a, int n, unsigned x)
{
unsigned long long L = 0, R = 100000000 - 1;
	for(; L < R - 3; ) {
unsigned long long md = (R * (x - a[L]) + L * (a[R] - x)) / (a[R] - a[L]);
if(a[md] == x) return md; else if(a[md] < x) L = md + 1; else R = md - 1;
}
if(a[L] == x) return L;
if(a[L+1] == x) return L+1;
if(a[L+2] == x) return L+2;
	return L+3;
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #178.48 us12 KBAcceptedScore: 100


Judge Duck Online | 评测鸭在线
Server Time: 2026-04-21 08:51:04 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠