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. 来讲讲C#中的类

    1.什么是类? 面向对象的语言,最基本的就是类.在C#中,类是这样来定义的:类代表一组具有公共属性和行为的对象. 举个例子,现实生活中,人就是一个“类”,但这只是一个统称,指所有的人.我们要找个人一起 ...

  2. 使用微信api接口开发的框架

    <?php/** * 微信公众平台API */class WeixinChat{ private $token; private $appid; private $appsecret; priv ...

  3. Bootstrap_排版_表格

    一.基础表格 <table class="table"> <thead> <tr> <th>表格标题</th> < ...

  4. C#快递单号查询源码

    源码本人测试过,没有啥问题,能查询快递单号,支持的快递还挺多,圆通快递.申通快递.韵达快递的都支持单号查询的,程序是通过向爱快递(www.aikuaidi.cn)接口传输参数来查询快递单号,我直接把代 ...

  5. Activity singleTop启动模式

    栈顶单例模式 和standard模式一样,  只有Activity已经存在并且位于栈顶时, 不会重新创建. 其他时候都会创建新的Activity,然后放在栈顶

  6. 2016030204 - git和github结合

    1.下载和安装git客户端 参考:http://www.cnblogs.com/zhtzyh2012/p/5232291.html 2.github上创建项目 参考:http://www.cnblog ...

  7. 编程思想—面向切面编程(AOP)

    谈到面向切面的编程,我们很容易关联到面向对象编程(OOP).个人对这两种编程方式的解释为:两种编程思想只是站在编程的角度问题. OOP注重的是对象,怎么对对象行为和方法的抽象.如何封装一个具有完整属性 ...

  8. Sublime text 3 快键方式汇总 及 主题应用

    Sublime Text 3 快捷键汇总 Sublime Text 3是款非常实用代码编辑神器,但是想要用任何一款软件,掌握一些快捷键还是很有必要的. 选择类 Ctrl+D 选中光标所占的文本,继续操 ...

  9. c#中的整形类型

    一.整型类型 C#中定义了8中整数类型:字节型(byte).无符号字节型(ubyte).短整型(short).无符号短整型(ushort).整型(int).无 符号整型(uint).长整型(long) ...

  10. C语言 rand()函数的用法

    rand()(产生随机数) 相关函数 srand() 表头文件 #include<stdlib.h> 定义函数 int rand()(void) 函数说明 rand()会返回一随机数值,范 ...