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. idea注册码激活防和谐

    1.到网站 http://idea.lanyus.com/ 获取注册码: 2.修改hosts文件,位于C:\Windows\System32\drivers\etc,添加一行,win10推荐使用not ...

  2. 网络编程之python zeromq学习系列之一

    简介: zeromq中间件,他是一个轻量级的消息中间件,传说是世界上最快的消息中间件,为什么这么说呢? 因为一般的消息中间件都需要启动消息服务器,但是zeromq这厮尽然没有消息服务器,他压根没有消息 ...

  3. Postgresql获取所有schema

    Postgresql 连接方式_连接五要素_psql: https://blog.csdn.net/u011402596/article/details/38510547 postgresql的sho ...

  4. jQuery插件开发中$.extend和$.fn.extend辨析

    jQuery插件开发分为两种:   1 类级别 类级别你可以理解为拓展jquery类,最明显的例子是$.ajax(...),相当于静态方法. 开发扩展其方法时使用$.extend方法,即jQuery. ...

  5. 即时新闻展示插件jQuery News Ticker,超级简单!

    有时候我们为了节省页面空间,会在页面明显处放一小条,用来展示比较重要的即时新闻,一般以轮播的形式出现.今天要介绍的jQuery News Ticker插件就是用来实现这个即时新闻展示功能的,效果图如下 ...

  6. 小玩意1-实时获取IE浏览器输入框URL地址

    主要参考http://www.cnblogs.com/scrat/archive/2012/09/12/2682626.html 主要思路如下: 通过 FindWindow() FindWindowE ...

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

    20155310 2016-2017-2 <Java程序设计>第六周学习总结 教材学习内容总结 4.1 Y86指令集体系结构 •有8个程序寄存器:%eax.%ecx.%edx.%ebx.% ...

  8. .NET 下第一次接触Redis数据库

    关于Redis 1.简介 Redis是著名的NOSQL(Not Only SQL)数据库,是键值对结构.(我只用过键值对结构的) 他为存储键值对做了优化,在大型网站中应用广泛.Redis提供了数据的自 ...

  9. C# 中printDocument打印、预览、打印机设置和打印属性的方法

    private void Form1_Load(object sender, System.EventArgs e) { //获取或设置一个值,该值指示是否发送到文件或端口 printDocument ...

  10. numpy 矩阵操作

    numpy 对矩阵对角线.上三角.下三角以及它们所在位置索引的提取 import numpy as np a = np.random.randint(0,10,[5,5]) print(a) # c ...