适用于无约束、单变量或一个自由度问题
#include<iostream>
#include<vector>
#include<limits>
#include<cmath>
#include<algorithm>
using namespace std;
vector<int> vect(46);
int feibo(int n){
if(vect[n] != 0) return vect[n];
int ans;
if(n <= 1) ans = 1;
else ans = feibo(n-1) + feibo(n-2);
vect[n] = ans;
return ans;
}
double func(double x){
return pow(x,2) - 6.0*x + 2.0;
}
int main(){
feibo(45);
// for(auto it : vect) cout<<it<<" ";
double a,b,error;
double pre_x=INT_MIN,pre_y=INT_MIN;
cin>>a>>b>>error;
int n = lower_bound(vect.begin(),vect.end(),ceil(1/error)) - vect.begin();
cout<<n<<endl;
while(n>0){
double l = (pre_x==INT_MIN)?(vect[n-1]*1.0*(b-a)/vect[n]):(pre_x - a);
double x1 = a+l,x2 = b-l;
double y1 = (x1=