hdu 2899 三分
#include<stdio.h>
#include<math.h>
#define ii 1e-9
double f(double x,double y) {
return 6*pow(x,7)+8*pow(x,6)+7*pow(x,3)+5*pow(x,2)-y*x;
}
int main() {
int t,n;
double start,end,mid,midd;
scanf("%d",&t);
while(t--) {
scanf("%d",&n);
start=0.0;
end=100.0;
while(end-start>ii) {
mid=(start+end)/2;
midd=(mid+end)/2;
if(f(mid,n*1.0)>f(midd,n*1.0))
start=mid;
else
end=midd;
}
printf("%.4f\n",f(end,1.0*n));
}
return 0;
}
浙公网安备 33010602011771号