You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
777 B
C++
30 lines
777 B
C++
#include <cstdio>
|
|
#include <cmath>
|
|
#include <algorithm>
|
|
using namespace std;
|
|
//F(x) = 6 * x^7+8*x^6+7*x^3+5*x^2-y*x
|
|
double f1(double x, double y) { return 6 * pow(x, 7) + 8 * pow(x, 6) + 7 * pow(x, 3) + 5 * pow(x, 2) - y * x; }
|
|
double f2(double x, double y) { return 42 * pow(x, 6) + 48 * pow(x, 5) + 21 * pow(x, 2) + 10 * x - y; }
|
|
int main()
|
|
{
|
|
int T;
|
|
double y, ans, tmp, ans1;
|
|
scanf("%d", &T);
|
|
while (T--)
|
|
{
|
|
ans = 1e100;
|
|
scanf("%lf", &y);
|
|
double l = 0, r = 100, m;
|
|
while (abs(r - l) > 1e-6)
|
|
{
|
|
m = (l + r) / 2;
|
|
if (f2(m, y) > 0)
|
|
r = m;
|
|
else
|
|
l = m;
|
|
}
|
|
printf("%.4lf\n", f1(m, y));
|
|
}
|
|
return 0;
|
|
}
|