传送门

题目大意:求 F(x) = 6 * x^7+8*x^6+7*x^3+5*x^2-y*x (0 <= x <=100);的最小值

题解:求个导,二分导函数零点,就是原函数最小值所在的x。

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#define LL long long
using namespace std; int T; LL y; double cal(double x)
{
return .*pow(x,)+.*pow(x,)+.*pow(x,)+.*x-y;
} double mul(double x)
{
return .*pow(x,)+.*pow(x,)+.*pow(x,)+.*pow(x,)-y*x;
} int main()
{
scanf("%d",&T);
while(T--)
{
scanf("%lld",&y);
double ans,l=,r=;
while(r-l>1e-)
{
double mid=(l+r)/;
// cout<<mid<<endl;
if(cal(mid)<=) ans=mid,l=mid;
else r=mid;
}
double res=mul(ans);
printf("%.4lf\n",res);
}
return ;
}
05-12 17:02