HDU 2199 Can you solve this equation?(二分精度)
Now please try your lucky.
InputThe 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);OutputFor 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! 这种题一般都很注重精度的,可以拿两个端点来做验证,6的时候应该为0.0000,807020306的时候应该为100.0000
其中while(ri-le<=0.000000001)这里的0尽量多一点,而判断的时候的0的个数要看情况,有些当满足
ri-le<=0.000000001时,说不定判断还不满足。
#include <iostream>
#include <stack>
#include <string.h>
#include <stdio.h>
#include<queue>
#include<algorithm>
#define ll long long
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
double y;
cin>>y;
double le,ri,mid;
le=;ri=;
bool f=;
while(ri-le>=0.00000000000001)
{
mid=(le+ri)/;
//cout<<8*mid*mid*mid*mid+7*mid*mid*mid+2*mid*mid+3*mid+6-y<<endl;
if(*mid*mid*mid*mid+*mid*mid*mid+*mid*mid+*mid+-y<0.00001&&*mid*mid*mid*mid+*mid*mid*mid+*mid*mid+*mid+-y>=)
{
f=;
break;
}
else if(*mid*mid*mid*mid+*mid*mid*mid+*mid*mid+*mid+-y<)
{
le=mid;
}
else
ri=mid;
}
if(f)
printf("%.4lf\n",mid);
else
printf("No solution!\n");
}
return ;
}
HDU 2199 Can you solve this equation?(二分精度)的更多相关文章
- 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?(高精度二分)
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?(二分解方程)
传送门: 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?【二分查找】
解题思路:给出一个方程 8*x^4 + 7*x^3 + 2*x^2 + 3*x + 6 == Y,求方程的解. 首先判断方程是否有解,因为该函数在实数范围内是连续的,所以只需使y的值满足f(0)< ...
- hdu 2199 Can you solve this equation?(二分搜索)
Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ( ...
随机推荐
- maven3官网下载地址
maven3官网下载地址:https://archive.apache.org/dist/maven/maven-3/
- NO.1 在Eclipse中安装Maven插件安装详解
前言 本来是没打算写博客的,作为一个13年毕业的菜鸟,自认为水平太渣写不出什么好文章,但是前些日子看到一篇鼓励性质的文章说,技术人员的成长靠的就是点点滴滴的积累,博客内容不一定包含多么高深的内容,但是 ...
- CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none 解决方法
参考:CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none 环境 主系统 OS X,虚拟机,Ubuntu 14.04 64bit. 问题描述 ...
- UVa 1636 决斗
https://vjudge.net/problem/UVA-1636 题意: 首先在手枪里随机装了一些子弹,然后抠了一枪,发现没有子弹.你希望下一枪也没有子弹,是应该直接再抠一枪还是随机转一下再抠. ...
- shell脚本监控Linux系统性能指标
2016-11-04 22:41 原作者不详 分类: Linux(7) 在服务器运维过程中,经常需要对服务器的各种资源进行监控, 例如:CPU的负载监控,磁盘的使用率监控,进程数目监控等等,以在系统出 ...
- 前端工程化 - gulp
gulp是什么 gulp就是一个前端的自动化构建工具,在开发过程中很多重复的任务可以使用gulp和gulp插件自动完成.相比于grunt,gulp非常好上手,核心API只有4个,而且还有丰富的插件库. ...
- shell 设置超时时间
等待20s后退出 a= b= while(true) do if [ $a -eq $b ] then echo "20s !!!" break else if [[ true ] ...
- Postman模拟高并发执行
一次,执行1000次. 看看服务器能否承受住. 查看每一次的执行情况,查看总的执行情况.成功情况,失败情况.
- java裁剪图片
java裁剪图片保存到指定位置 /** * 图片裁剪通用接口 * * @param src 源图片地址,图片格式PNG * @param dest 目的图片地址 * @param x 图片起始点x坐标 ...
- hdu 6386 Age of Moyu (重边判断)
本来用一个map判重边结果T了, 实际上可以直接给边上打标记即可 int n, m; struct _ {int to,w,vis;}; vector<_> g[N]; int dis[N ...