标签:acm 二分搜索 can you solve this e hdu2199 精度判定
2 100 -4
1.6152 No solution!
/**************************************
***************************************
* Author:Tree *
*From :http://blog.csdn.net/lttree *
* Title : Can you solve this equation?*
*Source: hdu 2119 *
* Hint : 二分搜索 *
***************************************
**************************************/
#include <stdio.h>
#define EPS 1e-6
double jdz(double a)
{
return a<0?-a:a;
}
double calcu( double x )
{
return 8*x*x*x*x+7*x*x*x+2*x*x+3*x+6;
}
double binary_s( int y )
{
double l,h,m;
l=0,h=100;
while( h-l>EPS )
{
m=(l+h)/2.0;
if( calcu(m)>y ) h=m;
else l=m;
}
return (l+h)/2.0;
}
int main()
{
int test,y;
scanf("%d",&test);
while(test--)
{
scanf("%d",&y);
if( y<=6 || y>=calcu(100) ) printf("No solution!\n");
else printf("%.4lf\n",binary_s( y ) );
}
return 0;
}
ACM-二分搜索之Can you solve this equation?——hdu2199,码迷,mamicode.com
ACM-二分搜索之Can you solve this equation?——hdu2199
标签:acm 二分搜索 can you solve this e hdu2199 精度判定
原文地址:http://blog.csdn.net/lttree/article/details/24791367