Homework Introduction
二分答案&算法
#include<bits/stdc++.h>
using namespace std;
long long a[15]={1,2,2,3,4,5,5,7,7,8};
int main(){
if(binary_search(a+0,a+10,6)==1){
cout << "Yes";
}
//binary_search(a+0,a+10,6) 在[0,9]找6,找到了返回true,否则返回false
cout << lower_bound(a+0,a+6,13)-a<< endl;//第一个大于等于 x 的位置
cout << upper_bound(a+0,a+10,7)-a;//第一个大于 x 的位置
return 0;
}
Problem
Please claim the assignment to see the problems.
- Status
- Live...
- Problem
- 15
- Open Since
- 2025-7-5 0:00
- Deadline
- 2025-8-26 23:59
- Extension
- 24 hour(s)