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 ( ...
随机推荐
- Java 8 Optional 良心指南,建议收藏
想学习,永远都不晚,尤其是针对 Java 8 里面的好东西,Optional 就是其中之一,该类提供了一种用于表示可选值而非空引用的类级别解决方案.作为一名 Java 程序员,我真的是烦透了 Null ...
- C++ 结构体sturct练习
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> struct Student { ];// 姓名 int id; //id int a ...
- mycli初体验
一.安装 pip install mycli 二.使用 mycli --help 三.特点 语法不全,高亮等
- Crypto++ 无法解析的外部符号 CryptoPP::AssignIntToInteger
预处理器定义中添加:CRYPTOPP_NO_ASSIGN_TO_INTEGER 方案出自:https://github.com/weidai11/cryptopp/issues/389
- Python习题集(十三)
每天一习题,提升Python不是问题!!有更简洁的写法请评论告知我! https://www.cnblogs.com/poloyy/category/1676599.html 题目 写一个函数,该函数 ...
- C#基础--迭代器初识
foreach语句是枚举器(enumerator)的消费者,而迭代器(iterator)是枚举器的产生者. 迭代器模式能提供一种顺序访问一个集合内部的元素,而又不会暴露其内部的方法.当然其缺点就是用f ...
- MassDNS:跨域DNS枚举工具
MassDNS:跨域DNS枚举工具 simeon 原文地址:http://offsecbyautomation.com/Use-MassDNS/ 工具地址:https://github.com/ble ...
- MySQL学习(3)
一 SQL语句 1. 数据库级别(*) 显示全部数据库:show databases; 创建数据库:create database '数据库名字’; 使用数据库:use '数据库名字'; 删除数据库: ...
- Visual Studio2019+OpenCV3.4.9环境搭建
让人头疼的vs2019+opencv环境配置 准备: visual studio2019: opencv 3.4.9: 耐心: 说明:vs2019属性管理器没有Microsoft.Cpp.x64.us ...
- [字典树,trie树] 树之呼吸-肆之型-前缀统计
D.树之呼吸-肆之型-前缀统计 Time Limit: 1000 MS Memory Limit: 65536 K Total Submit: 59 (8 users) Total Accepted: ...