提交记录 22616


用户 题目 状态 得分 用时 内存 语言 代码长度
TSKY 1003. 测测你的二分查找 Accepted 100 77.42 us 12 KB C 409 B
提交时间 评测时间
2024-10-19 19:23:34 2024-10-19 19:23:37
int binary_search(const unsigned *a, int n, const unsigned x)
{
	unsigned long long l = 0, r = n - 1;
	while (l < r)
	{
		unsigned long long l_num = a[l];
		unsigned long long r_num = a[r];
		unsigned long long mid = (r * (x - l_num) + l * (r_num - x)) / (r_num - l_num);
		if (a[mid] == x)
		{
			return mid;
		}
		else if (a[mid] < x)
		{
			l = mid + 1;
		}
		else
		{
			r = mid - 1;
		}
	}
	return l;
}


CompilationN/AN/ACompile OKScore: N/A

Testcase #177.42 us12 KBAcceptedScore: 100


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