https://www.jianshu.com/p/9e384b4a2588
二分用于单调
三分用于凹凸函数
模板提:
#include<bits/stdc++.h> using namespace std; const double eps=1e-6; double y; double check(double x){ return pow(x,7)*6+pow(x,6)*8+pow(x,3)*7+pow(x,2)*5-x*y; } int main() { int t; scanf("%d",&t); while(t--) { scanf("%lf",&y); // cin>>y; double l,r,midl,midr; l=0,r=100; while(r-l>eps){ midl=(l+r)/2; midr=(midl+r)/2; if(check(midl)>check(midr)) l=midl; else r=midr; } printf("%.4f\n",check((r+l)/2)); } }
原文:https://www.cnblogs.com/hgangang/p/11787734.html