本题是一道二分的题,核心就是mi的大小,即精度的取值。因为原函数是一个单调递增的函数,所以可以确定y的取值范围,并且在范围内的每一个y的值,一定至少存在一个x与其对应。刚开始我将取二分这个环节用一个函数来表示的,但是返回值始终是一个随机值,实在是搞不懂,无奈之下只能将那个步骤直接写在主函数内。。。

#include"iostream"
#include"stdio.h"
#include"algorithm"
#include"string.h"
#include"cmath"
#define mi 1e-8
using namespace std;
double cf(double x)
{
return *x*x*x*x + *x*x*x + *x*x + *x + ;
}
int main()
{
int t;
cin>>t;
while(t--)
{
double y;
cin>>y;
if(y< || y>)
{
printf("No solution!\n");
continue;
}
double x1=0.0,x2=100.0;
while(x2-x1>mi)
{
double x=(x2+x1)/2.0;
if(cf(x)>y) x2=x;
else x1=x;
}
printf("%.4lf\n",x1);
}
return ;
}

hdu Can you solve this equation?的更多相关文章

  1. hdu 2199 Can you solve this equation?(高精度二分)

    http://acm.hdu.edu.cn/howproblem.php?pid=2199 Can you solve this equation? Time Limit: 2000/1000 MS ...

  2. HDU 2199 Can you solve this equation?(二分精度)

    HDU 2199 Can you solve this equation?     Now,given the equation 8*x^4 + 7*x^3 + 2*x^2 + 3*x + 6 == ...

  3. HDU 2199 Can you solve this equation?(二分解方程)

    传送门: http://acm.hdu.edu.cn/showproblem.php?pid=2199 Can you solve this equation? Time Limit: 2000/10 ...

  4. ACM:HDU 2199 Can you solve this equation? 解题报告 -二分、三分

    Can you solve this equation? Time Limit: / MS (Java/Others) Memory Limit: / K (Java/Others) Total Su ...

  5. hdu 2199 Can you solve this equation?(二分搜索)

    Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K ( ...

  6. hdu 2199:Can you solve this equation?(二分搜索)

    Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K ( ...

  7. HDU 2199 Can you solve this equation? (二分 水题)

    Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K ( ...

  8. HDU 2199 Can you solve this equation(二分答案)

    Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K ( ...

  9. HDU - 2199 Can you solve this equation? 二分 简单题

    Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K ( ...

随机推荐

  1. echart所有汉字都显示中文,就echarts的toolbox注释显示乱码

    echarts无所谓支不支持gbk编码这么一说,关键是页面的charset和echarts.js文件的charset是否匹配,如果不匹配,请使用如下方式引入: <script src=" ...

  2. iOS 使用Storyboard 和 xib时的一些知识

    以前不太使用xib和storyboard进行布局,后来在工作中参与到了一个项目的维护工作,那个项目就是使用stroyboard的,再加上xcode5对stroyboard的大力支持,就在这里对于使用s ...

  3. Android中mesure过程详解

    我们在编写layout的xml文件时会碰到layout_width和layout_height两个属性,对于这两个属性我们有三种选择:赋值成具体的数值,match_parent或者wrap_conte ...

  4. 查看LINUX当前负载

    Linux的负载高,主要是由于CPU使用.内存使用.IO消耗三部分构成.任意一项使用过多,都将导致服务器负载的急剧攀升. [root@ok Desktop]# w 20:41:47 up  2:48, ...

  5. Zabbix discoverer processes more than 75% busy

    [root@86 ~]# grep -n "StartDiscoverers" /usr/local/zabbix/etc/zabbix_server.conf 176:### O ...

  6. Twitter search API

    Twitter crawler 与sina 微博类似,使用twitter api之前,首先要有twitter的账号,在twitter developer中创建应用(https://apps.twitt ...

  7. java web开发问题集合

    前台和后台的交流到底是借助什么?servlet?xml? 我们能感觉到用servlet,但是我们是如何使用servlet的?不是现在web.xml部署后,才能触发吗?所以其实我们是本质是借助XML文件 ...

  8. WCF例子

    WCF入门简单教程(图文) VS2010版 http://hi.baidu.com/grayworm/item/5bb61792fec5b54af142159f http://hi.baidu.com ...

  9. Centos 6.4 32位 gcc 升级(已验证)

    具体需要升级成什么版本自行下载https://gcc.gnu.org/ 本文升级为4.8.5 1.下载编译所需依赖库 cd gcc-4.8.5 ./contrib/download_prerequis ...

  10. Hark的数据结构与算法练习之冒泡排序

    算法说明: 冒泡排序实际上是使用的最多的排序,逻辑是循环然后对相邻的数字进行比较,并交换数据. 例如有一个数组int[] arrayData = { 2, 3, 1, 5, 6, 7, 4, 65, ...