【模板】三分
作者:互联网
对于单峰曲线,我们要用到三分。
double get(double x);
double divide(double l,double r) {
while(fabs(r-l) >= eps) {
double mid = (l+r)/2.0;
double lmid = mid-eps, rmid = mid+eps;
if(get(lmid) < get(rmid))
l = mid;
else
r = mid;
}
return get(l);
}
标签:get,rmid,double,eps,mid,lmid,模板,三分 来源: https://www.cnblogs.com/bikuhiku/p/3_devide.html