(二分) HDU 2199 Can you solve this equation?

......题目自理

简单就是好啊,都不想看题,最近.= =|||

#include<stdio.h>
#include<math.h>
#define eps 1.0e-10
double cal(double x)
{
	return (8.0*pow(x,4.0)+7.0*pow(x,3.0)+2.0*pow(x,2.0)+3.0*x+6.0);
}
int main()
{
	int t;
	double y;
	scanf("%d",&t);
	while(t--)
	{
		double left=0.0,right=100.0,mid;
		scanf("%lf",&y);
		if(cal(left)>y||cal(right)<y) printf("No solution!\n");
		else 
		{
			while(fabs(left-right)>eps)
			{
				mid=(left+right)/2;
				if(cal(mid)>y) right=mid;
				else left=mid;
			}
			printf("%.4lf\n",mid);
		}
	}
	return 0;
}


你可能感兴趣的:((二分) HDU 2199 Can you solve this equation?)