juzi1030 @ 2024-12-15 18:40:14
求调!!!!!!
#include<bits/stdc++.h>
using namespace std;
int n,m;
int a[10000001];
int hello(int x){
int l=1,r=n+1;
while(l+1<r){
int M=(l+r)/2;
if(a[M]<x){
l=M;
}
else{
r=M;
}
}
if(a[l]=x&&a[r]==x){
return r;
}
else{
return -1;
}
}
int main(){
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++){
scanf("%d",&a[i]);
}
for(int i=1;i<=m;i++){
int x;
scanf("%d",&x);
printf("%d",hello(x));
}
return 0;
}
by juzi1030 @ 2024-12-15 18:49:08
不用了,过了