| Run ID | Author | Problem | Lang | Verdict | Score | Time | Memory | Code Length | Submit Time |
|---|---|---|---|---|---|---|---|---|---|
| 110302 | 江婉儿 | 折半查找法 | C++ | Accepted | 100 | 1 MS | 296 KB | 357 | 2023-11-14 13:27:57 |
#include<bits/stdc++.h> using namespace std; int n,a[10010],c; void zhao(int m,int n) { int b=(m+n)/2; if(n-m==1) { cout<<"-1"; return; } if(c==a[b]) { cout<<b; return; } if(c<a[b]) zhao(m,b); if(c>a[b]) zhao(b,n); } int main() { cin>>n; for(int b=1;b<=n;b++) cin>>a[b]; cin>>c; zhao(0,n+1); return 0; }