您的位置:首页 > 其它

hdu2199

2015-07-15 21:03 357 查看
典型的二分。。。然而当初 搞了一上午

[code]#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
double Y;
double cal(double x)
{
  return 8.0*x*x*x*x+7.0*x*x*x+2.0*x*x+3.0*x+6.0;
}

int main()
{
    int T;
    scanf("%d",&T);
    while(T--)
    {
        scanf("%lf",&Y);
        if(Y<6||Y>807020306)
        {
            printf("No solution!\n");
            continue;
        }
        double l=0.0,r=100.0,mid;
        while(r-l>1e-8)
        {
            mid=(l+r)*0.5;
            if(cal(mid)>Y)
            {
                r=mid;
            }
            else
            {
                l=mid+1e-8;
            }
        }
        printf("%.4lf\n",mid);
    }
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: