2 100 -4
1.6152 No solution!
#include<iostream>
#include<cmath>
#include<stdio.h>
using namespace std;
double A(double x)
{
return (8*pow(x,4)+7*pow(x,3)+2*pow(x,2)+3*pow(x,1)+6);
}
int main()
{
double y;
int T;
cin>>T;
while(T--)
{
cin>>y;
if(A(0)>y||A(100)<y)
{
cout<<"No solution!"<<endl;
continue;
}
else{
double high,low,mid;
high=100;
low=0;
while(low+1e-8<high)
{
mid=(high+low)/2;
if(A(mid)>y)
high=mid;
else
low=mid;
}
printf("%.4lf\n",low);
}
}
return 0;
}
杭电 HDU ACM 2199 Can you solve this equation?
原文:http://blog.csdn.net/lsgqjh/article/details/45417913