zaozao001 @ 2023-09-03 14:48:53
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<algorithm>
using namespace std;
long long int a[10001];
int main(){
long long int n,m,q;
cin>>n>>m;
for(int i=1;i<=n;i++){
cin>>a[i];
}
for(int i=1;i<=m;i++){
cin>>q;
long long int l=1,h=1e18;
while(l<=h){
int mid=(l+h)/2;
if(a[mid]>=q){
h=mid-1;
}else{
l=mid+1;
}
}
if(a[l]==q)cout<<l;
else cout<<-1;
cout<<" ";
}
return 0;
}
(RE)
by Regenbogen_71 @ 2023-09-03 14:53:04
@zaozao001 数组开小了
by zaozao001 @ 2023-09-03 14:59:04
a[10000001]这么大也不对
by Lose_Control @ 2023-09-03 15:19:50
@zaozao001 ???
by zaozao001 @ 2023-09-03 15:27:03
@HJX111215 就是我,怎么了
by Score_Elevate @ 2023-09-09 21:00:56
@zaozao001 h不应该为1e18
by Score_Elevate @ 2023-09-09 21:05:07
@zaozao001 h应为n,你的方法不对