二分专题

二分专题

 

int p=lower_bound(A,A+n,x)-A;          //查询>=x的第一个下标
int p=upper_bound(A,A+n,x)-A;          //查询>x的第一个下标
int p=upper_bound(A,A+n,x)-A-1;         //查询<=x的最后一个下标
int p=lower_bound(A,A+n,x)-A-1;         //查询<x的最后一个下标
int n=upper_bound(A,A+n)-lower_bound(A,A+n);  //查询等于x的数量

  

 

posted @ 2015-07-19 13:28  Running_Time  阅读(186)  评论(0编辑  收藏  举报