#include <bits/stdc++.h>
using namespace std;
//F(x) = 6*x^7+8*x^6+7*x^3+5*x^2-y*x (0 <= x <=100)
#define F(x, y) (x*(x*(x*(x*(x*(x*(6*x+8)))+7)+5)-y))
double solve(double l, double r, double y){
double lm, rm;
while(r - l > 1e-7){
lm = (2*l+r)/3;
rm = (l+2*r)/3;
if(F(lm, y)>F(rm, y))l = lm;
else if(F(lm, y)<F(rm, y)) r = rm;
else l = lm, r = rm;
}
return F((l+r)/2, y);
}
int main(){
int T;
double y;
scanf("%d", &T);
while(T--){
scanf("%lf", &y);
printf("%.4f\n", solve(0, 100, y));
}
return 0;
}
hdu 2899 Strange fuction
最新推荐文章于 2022-07-19 16:47:04 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)