/*
* hdu2899.c
*
* Created on: 2011-10-9
* Author: bjfuwangzhu
*/

#include<stdio.h>
#include<math.h>
#define eps 1.0e-8
double ff(double x, double y) {
return 42.0 * pow(x, 6.0) + 48.0 * pow(x, 5.0) + 21.0 * pow(x, 2.0)
+ 10.0 * x - y;
}
double f(double x, double y) {
return 6.0 * pow(x, 7.0) + 8.0 * pow(x, 6.0) + 7.0 * pow(x, 3.0)
+ 5.0 * pow(x, 2.0) - y * x;
}
double bfsearch(double y) {
double left, right, mid;
left = 0.0, right = 100.0;
while (fabs(left - right) > eps) {
mid = (left + right) / 2.0;
if (ff(mid, y) < 0.0) {
left = mid;
} else {
right = mid;
}
}
return mid;
}
int main() {
#ifndef ONLINE_JUDGE
freopen("data.in", "r", stdin);
#endif
int t;
double y, x;
scanf("%d", &t);
while (t--) {
scanf("%lf", &y);
x = bfsearch(y);
printf("%.4lf\n", f(x, y));
}
return 0;
}

 

相关文章:

  • 2022-02-04
  • 2021-05-15
  • 2022-12-23
  • 2022-12-23
  • 2021-08-31
  • 2021-08-16
  • 2021-10-19
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-01-24
  • 2021-05-22
  • 2021-09-01
  • 2022-12-23
  • 2021-11-12
相关资源
相似解决方案