Can you solve this equation?

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 12766    Accepted Submission(s):
5696

Problem Description
Now,given the equation 8*x^4 + 7*x^3 + 2*x^2 + 3*x + 6
== Y,can you find its solution between 0 and 100;
Now please try your
lucky.
 
Input
The first line of the input contains an integer
T(1<=T<=100) which means the number of test cases. Then T lines follow,
each line has a real number Y (fabs(Y) <= 1e10);
 
Output
For each test case, you should just output one real
number(accurate up to 4 decimal places),which is the solution of the equation,or
“No solution!”,if there is no solution for the equation between 0 and 100.
 
Sample Input
2
100
-4
 
Sample Output
1.6152
No solution!
#include<stdio.h>
#include<string.h>
double f(double v)//用来计算方程结果(即y的值)
{
return 8*v*v*v*v+7*v*v*v+2*v*v+3*v+6;
}
int main()
{
int t;
double y,l,r,mid;
scanf("%d",&t);
while(t--)
{
scanf("%lf",&y);
if(y<f(0)||y>f(100))
{
printf("No solution!\n");
continue;
}
l=0;r=100;mid=0;
while((r-l) > 1e-10)//题目要求精度为小数点后四位,最好把精度调高
{
mid=(l+r)/2;//每次折半取x的范围
if(f(mid) < y)
l=mid;
else
r=mid;
}
printf("%.4lf\n",mid);
}
}

  

hdoj 2199 Can you solve this equation?【浮点型数据二分】的更多相关文章

  1. 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 ...

  2. Hdoj 2199.Can you solve this equation? 题解

    Problem Description Now,given the equation 8x^4 + 7x^3 + 2x^2 + 3x + 6 == Y,can you find its solutio ...

  3. hdoj 2199 Can you solve this equation? 【二分枚举】

    题意:给出一个数让你求出等于这个数的x 策略:如题. 由于整个式子是单调递增的.所以能够用二分. 要注意到精度. 代码: #include <stdio.h> #include <s ...

  4. HDU 2199 Can you solve this equation? 【浮点数二分求方程解】

    Now,given the equation 8x^4 + 7x^3 + 2x^2 + 3x + 6 == Y,can you find its solution between 0 and 100; ...

  5. 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 ...

  6. 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 == ...

  7. 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 ...

  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. Codevs 2549 自然数和分解

    2549 自然数和分解 时间限制: 1 s 空间限制: 32000 KB 题目等级 : 白银 Silver 传送门 题目描述 Description 把自然数N分解为若干个自然数之和,输出方案数. 输 ...

  2. PC110302/UVA10010

    下周开始就省选了,ACM的日子在今年内应该就会结束了,大三了,最后一次机会了,小小感伤一下-- 今天广州下大雨,心情怪怪的,感觉码不出质量高的,又很久没做过PC了,就刷刷水题吧. 老实说Program ...

  3. 关于Apple设备私有的apple-touch-icon属性详解

    以前我们用过favicon在浏览器给网站进行身份标识,用法如下: <link href="http://image.feeliu.com/web/favicon.ico" r ...

  4. 将[{},{}]转为dict

    经常遇到一种需求,需要把从数据库取出的数据,转为dict对象([{}, {},...]-->dict). rs = [{, , "name":"edf"} ...

  5. ecshop安装程序源码阅读-安装脚本(2)

    检查环境变量: 程序目录:图片目录,数据目录,临时目录 模板目录下模板文件 数据库连接函数 数据库配置: 读取数据库列表 创建配置文件(数据库,语言,session有效期等) 创建数据表 创建初始化数 ...

  6. session与cookie的区别,有哪些不同之处

    session与cookie的区别,根据自己的理解总结如下: (1)cookie是一种客户端的状态管理技术,将状态写在 浏览器端,而session是一种服务器端的状态管理技术,将 状态写在web服务器 ...

  7. Laravel之路——事务

    准备: 表必须是InnoDB引擎 DB::beginTransaction(); try{ $name = 'abc'; $result1 = Test::create(['name'=>$na ...

  8. phonegap 4.2 环境搭建 及 项目创建 运行

    安装Java 和 ADT 1.首先要安装java运行环境jdk,这个可以自行到官网下载.百度也有下载连接:( http://www.baidu.com/s?tn=baidu&ie=utf-8& ...

  9. [转]hive中order by,distribute by,sort by,cluster by

    转至http://my.oschina.net/repine/blog/296562 order by,distribute by,sort by,cluster by  查询使用说明 1 2 3 4 ...

  10. IndexedDB

    http://www.tfan.org/indexeddb/ http://fnvfox.appspot.com/thankyou.html http://www.tfan.org/wechat-on ...