标签:int online sub desc == lin hint com main
本人水平有限,题解不到为处,请多多谅解
本蒟蒻谢谢大家观看
5
1
2
5
7
.....
3
code:
#include<bits/stdc++.h> using namespace std; int x; int a[1501]; int main() { int left=1,right=1500,mid,find=-1; cin>>x; for(int i=1;i<=1500;i++) cin>>a[i]; while(left<=right) { mid=(left+right)/2; if(a[mid]==x){ find=mid; break; } if(a[mid]<x) { left=mid+1; } if(a[mid]>x) { right=mid-1; } } cout<<find; //freopen("yzlak.in","r",stdin); //freopen("yzlak.out","w",stdout); }
标签:int online sub desc == lin hint com main
原文地址:https://www.cnblogs.com/nlyzl/p/11357152.html