Can you solve this equation
Problem Description
Now,given the equation 8*x^4 + 7*x^3 + 2*x^2 + 3*x + 6 == Y,can you find its solution between 0 and 100;
Now please try your lucky.
Now please try your lucky.
Input
The first line of the input contains an integer T(1<=T<=100) which means the number of test cases. Then T lines follow, each line has a real number Y (fabs(Y) <= 1e10);
Output
For each test case, you should just output one real number(accurate up to 4 decimal places),which is the solution of the equation,or “No solution!”,if there is no solution for the equation between 0 and 100.
Sample Input
2 100 -4
Sample Output
1.6152 No solution! #include<iostream>
#include<math.h>
#include<stdio.h>
using namespace std;
#define num 807020306
double cal(double x)
{
return 8*x*x*x*x+7*x*x*x+2*x*x+3*x+6;
}
double y;
double gcd(double head,double rear)
{
double mid;
while(rear-head>1.0e-7)
{
mid=(head+rear)/2;
if(cal(mid)<y) head=mid;
else rear=mid;
}
return rear;
}
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
scanf("%lf",&y);
if(y<6||y>num) cout<<"No solution!"<<endl;
else printf("%.4lf\n",gcd(0.0,100.0));
}
return 0;
}
为了明天所以选择坚定的执着今天。