Can you solve this equation?

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)

Total Submission(s): 22742    Accepted Submission(s): 9865


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>
const double eps = 1e-8;//精度大胆设高些 double cal(double x,double y)
{
double m;
m = 8 * x*x*x*x + 7 * x*x*x + 2 * x*x + 3 * x + 6 - y;
return m;
} double bsearch(double y)
{
double left = 0, right = 100;
double mid;
while (right - left > eps)
{
mid = (left + right) / 2;
if (cal(mid, y)>0)
{
right = mid;
}
else
{
left = mid;
}
}
return mid;
} int main()
{
int T;
scanf("%d", &T);
double M,n;
while (T--)
{
scanf("%lf", &M);
if (M < 6 || M>807020306)//注意上下界
{
printf("No solution!\n");
}
else
{
n=bsearch(M);
printf("%.4lf\n", n);
}
}
return 0;
}

HDU - 2199 Can you solve this equation? 二分 简单题的更多相关文章

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

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

  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? 二分

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

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

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

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

  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?【二分查找】

    解题思路:给出一个方程 8*x^4 + 7*x^3 + 2*x^2 + 3*x + 6 == Y,求方程的解. 首先判断方程是否有解,因为该函数在实数范围内是连续的,所以只需使y的值满足f(0)< ...

  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. 如何定制Gtk版Emacs的Widget外观

    当我们使用 xlib 版的Emacs时,可以通过 XResource 定义 Emacs 的菜单 栏.工具条.滚动条的外观. 现在,在Linux上我们大多使用 gtk版的Emacs,是否还有办法定义 E ...

  2. 20155231 2016-2017-2 《Java程序设计》第7周学习总结

    20155231 2016-2017-2 <Java程序设计>第7周学习总结 教材学习内容总结 学习目标 了解Lambda语法 了解方法引用 了解Fucntional与Stream API ...

  3. vtk 基础概念

    #include <vtk-5.10/vtkSmartPointer.h>#include <vtk-5.10/vtkRenderWindow.h>#include <v ...

  4. 简单对象List自定义属性排序

    <body> <div> sort()对数组排序,不开辟新的内存,对原有数组元素进行调换 </div> <div id="showBox" ...

  5. golang的json序列化

    json就是简单的数据交换格式,语法类似javascript的对象和列表,是最常见的后端和运行在网页上的js之间的通信格式. encoding: 编码json数据需要使用到Marshal()函数. f ...

  6. JS事件用法

    1.常用事件理解

  7. 【bzoj题解】2186 莎拉公主的困惑

    题目传送门. 题意:求\([1,n!]\)中与\(m!\)互质的数的个数,对质数\(R\)取模,\(n\geq m\). 答案应该等于\(\frac{n!}{m!}\phi(m!)=\frac{n!} ...

  8. Linux学习笔记-文件处理和权限命令

    目录 文件处理命令 touch cat tac more less head tail 链接命令 ln 权限命令 chmod 权限管理命令 chown chgrp umask 文件处理命令 touch ...

  9. OpenFlow1.3协议wireshark抓包分析

    OpenFlow v1.0 v1.0协议消息列表如下: 分为三类消息:Controller-to-switch,asynchronous和symmertric. v1.0(包含至少一个流表,每个流表包 ...

  10. 27 Debugging Go Code with GDB 使用GDB调试go代码

    Debugging Go Code with GDB  使用GDB调试go代码 Introduction Common Operations Go Extensions Known Issues Tu ...