提交时间:2023-11-08 13:25:18

运行 ID: 109303

#include<bits/stdc++.h> using namespace std; int an[10000]; double l; bool mn=0; void sb(int x,int y) { if(x==y&&l!=x){ cout<<"-1"; exit(0); } if(l==an[(x+y)/2]){ cout<<(x+y)/2; }else{ if((x+y)/2>l){ sb((x+y)/2,1); }else{ sb((x+y)/2,1); } } } int main() { int a; cin>>a; for(int i=1;i<=a;i++){ cin>>an[i]; } cin>>l; sb(1,a); return 0; }