xzh20232914 @ 2024-03-07 20:52:04
#include<stdio.h>
long long int a[1000000];
int main()
{
long long int n,m,i,mid;
long long int b;
scanf("%lld%lld",&n,&m);
for(i=0;i<n;i++)
scanf("%lld",&a[i]);
while(m--)
{
mid=n/2;
scanf("%lld",&b);
while(a[mid]>=b)
{
mid--;
}
while(a[mid]<b)
{
mid++;
}
if(a[mid]==b)
printf("%lld ",mid+1);
else
printf("-1 ");
}return 0;
}
by sybnb @ 2024-03-07 20:53:43
这是什么二分查找???