C - Can you solve this equation? HDU - 2199(二分水题)
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(二分水题)的更多相关文章
- (二分搜索)Can you solve this equation? -- hdu -- 2199
链接: http://acm.hdu.edu.cn/showproblem.php?pid=2199 Time Limit: 2000/1000 MS (Java/Others) Memory ...
- 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 ...
- 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 == ...
- 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 ...
- 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 ...
- hdu 2199 Can you solve this equation?(二分搜索)
Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ( ...
- hdu 2199:Can you solve this equation?(二分搜索)
Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ( ...
- HDU 2199 Can you solve this equation? (二分 水题)
Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ( ...
- HDU 2199 Can you solve this equation(二分答案)
Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ( ...
随机推荐
- Yuchuan_Linux_C编程之六 Makefile项目管理
一.整体大纲 二.makefile的编写 一个规则 两个函数 三个变量 1. 一个规则 三要素:目标, 依赖, 命令 目标:依赖 命令: 第一条规则是用来生成终 ...
- 一次生产环境搭建11g RAC的记录
一.使用惠普3par工具配置共享存储 该部分可由惠普工作人员协助配置,只需将需求告知即可.如果想自己配置,惠普厂商会发送相关的软件工具以及操作手册给用户. 用putty登陆共享存储,使用showpd ...
- 大数据篇:ElasticSearch
ElasticSearch ElasticSearch是什么 ElasticSearch是一个基于Lucene的搜索服务器.它提供了一个分布式多用户能力的全文搜索引擎,基于RESTful web接口. ...
- 用反射机制和pandas,实现excel数据的读取以及参数化${arg}的赋值
反射类:class GetData: index = pd.read_excel(file_name, sheet_name).loc[0, ['index']].values[0] email = ...
- flask blueprint出现的坑
from flask import Blueprint admin = Blueprint('admin',__name__) def init_bule(app): app.register_blu ...
- MySQL中SQL Mode的查看与设置
MySQL可以运行在不同的模式下,而且可以在不同的场景下运行不同的模式,这主要取决于系统变量 sql_mode 的值.本文主要介绍一下这个值的查看与设置,主要在Mac系统下. 对于每个模式的意义和作用 ...
- WEB应用之http协议和httpd闲聊
什么是web?在日常生活中我们常常听到web这个词,它到底是什么呢?今天我们来聊一聊web应用http协议:相信生活在如今互联网时代的我们,http这个协议应该对我们不是很陌生吧!比如双十一双十二我们 ...
- .NET 5 Preview 1中的ASP.NET Core更新 (2020年3月16日)
.NET 5 Preview1现在可用,可以进行评估了! .NET 5将是当前版本. 开始 要在.NET 5.0中开始使用 ASP.NET Core,请安装.NET 5.0 SDK. 如果您使用的是W ...
- typescript package.json vscode 终端 运行任务 Ctrl shift B
{ "dependencies": { "typescript": "^3.6.4" } }
- DVWA(七):XSS(stored)存储型XSS攻击
存储型XSS : 存储XSS,会把攻击者的数据存储在服务器端,攻击行为将伴随着攻击数据一直存在.提交JS攻击代码存储到数据库然后再输出. low: 观察源码: <?php if( isset( ...