Now,given the equation 8x^4 + 7x^3 + 2x^2 + 3x + 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<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std; #define ll long long
#define db double
const int Len = 1e5+10; db Cal(db m)
{
return 8 * pow(m, 4) + 7 * pow(m, 3) + 2 * pow(m, 2) + 3 * m + 6;
} int main()
{
//freopen("A.txt","r",stdin);
int t;
cin >> t;
while(t --)
{
int n;
scanf("%d", &n);
db l = 0, r = 100;
if(Cal(0) > n || Cal(100) < n)
cout << "No solution!\n";
else
{
db m;
while(r - l >= 1e-10)
{
m = (l + r)/2;
if(Cal(m) > n)
r = m;
else
l = m;
}
printf("%.4lf\n", m);
}
} return 0;
}

C - Can you solve this equation? HDU - 2199(二分水题)的更多相关文章

  1. (二分搜索)Can you solve this equation? -- hdu -- 2199

    链接: http://acm.hdu.edu.cn/showproblem.php?pid=2199 Time Limit: 2000/1000 MS (Java/Others)    Memory ...

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

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

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

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

  6. hdu 2199 Can you solve this equation?(二分搜索)

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

  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? (二分 水题)

    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. 1,Linux(CentOS)中的基本配置

    1,hostname(主机名) 查看主机名:hostname 临时修改主机名:hostname hadoop1 永久修改主机名:vi etc/sysconfig/network :  [NETWORK ...

  2. jenkins操作

    jenkins忘记用户名以及登录密码的解决方法 1.jenkins 根目录下找到config.xml,修改配置  <useSecurity>true</useSecurity> ...

  3. nes 红白机模拟器 第1篇

    对比了很多种,开源的 NES 模拟器 VirtuaNES , nestopia , FakeNES , FCEUX , InfoNES , LiteNES 最后决定使用 LiteNES 进行移值,它是 ...

  4. R中character和factor的as.integer的不同

    记录一个容易犯错的地方. 用chr标记的0~1变量可以变为整数0和1, 而用因子factor标记的变量转换为整数时总是从1开始. 如果不注意区分就会发生令自己困惑的错误.

  5. 每天都在用 Map,这些核心技术你知道吗?

    本篇文章站在多线程并发安全角度,带你了解多线程并发使用 HashMap 将会引发的问题,深入学习 ConcurrentHashMap ,带你彻底掌握这些核心技术. 全文摘要: HashMap 核心技术 ...

  6. GoJS学习笔记 (转)

    目录 基础概念 开始绘制图形 1. 通过代码构建图形 2. 通过 GraphObject.make 构建图形 3. 使用 Model 和 Templates 创建图形 获取图形数据 获取所有 Node ...

  7. Codeforces Round #378 (Div. 2)F

    题目:一个带权连通无向图,给第i条边权值减1需要花费ci元,你一共有S元,求最小生成树. 容易得出钱全部花在一条边上是最优的. 我们先做一遍最小生成树. 然后我们枚举减哪一条边. 如果这条边是树上的, ...

  8. 初学嵌入式Linux

    初学嵌入式Linux,感觉需要学习的东西太多了.把学习过程中的收获和问题记录在这里,算是一份经验吧.     前面利用开发板带的现成的东西step by step让Linux 2.4.19在开发板上跑 ...

  9. 基于《仙剑奇侠传柔情版》利用Java的简单实现(一)

    基于<仙剑奇侠传柔情版>利用Java的简单实现(一) 2018-12-01 23:55:36   by Louis  一,新建一个类GameFrame.class,具体代码如下: pack ...

  10. DOTNET CORE源码分析之IOC容器结果获取内容补充

    补充一下ServiceProvider的内容 可能上一篇文章DOTNET CORE源码分析之IServiceProvider.ServiceProvider.IServiceProviderEngin ...