#include<iostream>
#include<stdio.h>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<functional>
#include<set>
#include<map>
#include<cstdlib>
#include<vector>
#include<cmath>
#include <algorithm>
#pragma warning(disable:4996)
using namespace std;
double y;
double find(double x)
{
return 8 * pow(x, 4) + 7 * pow(x, 3) + 2 * pow(x, 2) + 3 * x + 6 - y;
}
double ef()
{
double l = 0, r = 100, mid;
while (r-l>=1e-8)
{
mid = (r + l) / 2;
if (find(mid) > 0)
r = mid;
else
l = mid;
}
return mid;
}
int main()
{
int t;
cin >> t;
while (t--)
{
cin >> y;
if (find(0)*find(100)>0)
cout << "No solution!" << endl;
else
printf("%.4lf\n", ef());
}
return 0;
}
B - Can you solve this equation?
最新推荐文章于 2021-03-27 10:33:55 发布