hdu Can you solve this equation?
本题是一道二分的题,核心就是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?的更多相关文章
- 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 ...
- 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 == ...
- 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 ...
- 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 ...
- hdu 2199 Can you solve this equation?(二分搜索)
Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ( ...
- hdu 2199:Can you solve this equation?(二分搜索)
Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ( ...
- HDU 2199 Can you solve this equation? (二分 水题)
Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ( ...
- HDU 2199 Can you solve this equation(二分答案)
Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ( ...
- HDU - 2199 Can you solve this equation? 二分 简单题
Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ( ...
随机推荐
- 70 数组的Kmin算法和二叉搜索树的Kmin算法对比
[本文链接] http://www.cnblogs.com/hellogiser/p/kmin-of-array-vs-kmin-of-bst.html [分析] 数组的Kmin算法和二叉搜索树的Km ...
- 使用kettle转换中的JavaScript对密码进行加密和解密
日常开发中,为了确保账号和密码的安全,时常要对密码进行加密和解密.然而kettle是怎么对密码进行加密和解密的呢? 下面的代码需要再转换中的JavaScript中运行. var encrypted_p ...
- iOS7中都Bar的透明问题
/* New behavior on iOS 7. Default is YES. You may force an opaque background by setting the property ...
- [Android Pro] 通过IMSI判断手机是移动、联通、电信
TelephonyManager telManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); /** 获取 ...
- 三种配置linux环境变量的方法(以java为例)
1.先确认是否为openjdk:参考 2. 修改/etc/profile文件 如果你的计算机仅仅作为开发使用时推荐使用这种方法,因为所有用户的shell都有权使用这些环境变量,可能会给系统带来安全性 ...
- Sublime Text 3 破解+ 汉化包
破解: 第一步:打开主文件搜索十六进制F7D81AC02005 修改1AC0为B001 第二步:搜索 F3FF8BC7E895 修改其中的8BC7为33C0 第三步:过阻拦未注册提示 搜索 0F859 ...
- php 增删改查练习
添加界面 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3 ...
- p188习题2
- .net学习之继承、里氏替换原则LSP、虚方法、多态、抽象类、Equals方法、接口、装箱拆箱、字符串
1.继承(1)创建子类对象的时候,在子类对象中会为子类对象的字段开辟空间,也会为父类的所有字段开辟空间,只不过父类私有的成员访问不到(2)子类从父类继承父类所有的非私有成员,但是父类的所有字段也会创建 ...
- hdu 1016 Prime Ring Problem(DFS)
Prime Ring Problem Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Other ...