三分法模板
double ternarySearch(double l,double r) { while(r-l < eps) { double mid = (l + r)/2; double midmid = (mid + r)/2; if(cal(mid) < cal(midmid)) { l = mid; } else { r = midmid; } } return l; }
double ternarySearch(double l,double r) { while(r-l < eps) { double mid = (l + r)/2; double midmid = (mid + r)/2; if(cal(mid) < cal(midmid)) { l = mid; } else { r = midmid; } } return l; }