1 bool check(){ 2 if(/*满足二分条件*/) 3 return true; 4 return false; 5 } 6 7 int erfen(int size){ 8 int left=0,right=size; 9 int mid; 10 while(left<right) 11 { 12 mid=(left+right)>>1; 13 if(check()) 14 left=mid+1; 15 else 16 right=mid; 17 } 18 return left; 19 }
原文:https://www.cnblogs.com/kohano/p/11745110.html