HDU 2199 Can you solve this equation?
 
 
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.

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?(二分精度)的更多相关文章

  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? 二分 简单题

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

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

    1.Qt570的简单测试项目,在做"重新构建"的操作的时候,出现1个问题,Qt底下的"编译输出"窗口中的信息为: cc1plus: error: unrecog ...

  2. 微信公众号开发之微信JSSDK

    概述 微信JS-SDK是微信公众平台面向网页开发者提供的基于微信内的网页开发工具包. 通过使用微信JS-SDK,网页开发者可借助微信高效地使用拍照.选图.语音.位置等手机系统的能力,同时可以直接使用微 ...

  3. 安装GraphicsMagick

    环境  CentOS7/CentOS7.1 x64 1.检查yum 2.检查是否安装zlib,下载地址:http://www.zlib.net/ 3.安装libpng,下载地址:http://www. ...

  4. [Python开发工具] Pycharm之快捷键

    [Python开发工具] Pycharm之快捷键 1 全局搜索: Ctrl+Shift+F,不过PyCharm的更强大, 你可以点选左侧某个目录后再按Ctrl+Shift+F, 这样默认会搜索改目录; ...

  5. ASP.NET(c#) 日期选择控件的另一种实现方法

    这篇文章是在一个英文网站发现的,完全使用ASP.NET实现了日期选择的基本功能,没有使用js,原文链接http://geekswithblogs.net/plundberg/archive/2009/ ...

  6. 代码控制 textarea 控件是否为KindEditor 编辑框

    <script charset="utf-8" src="<%:Url.Content("~/UI/Scripts/KindEditor/kinde ...

  7. java并发编程之volatile

    Java语言规范第三版中对volatile的定义如下:Java编程语言允许线程访问共享变量,为了确保共享变量能被准确和一致地更新,线程应该确保通过排他锁单独获得这个变量. 了解volatile关键字之 ...

  8. Ubuntu下的计算器

    今天计算乘法时居然给算错了,好囧. 于是开始使用ubuntu自带的计算器:gcalctool 使用方法: 在终端直接输入命令gcalctool即可.

  9. 高性能Mysql学习笔记之事务

    传送门 什么是事务? 事务就是一组原子性的SQL查询,或者说一个独立的工作单元.如果数据库引擎能够成功地对数据库应用该组查询的全部语句,那么就会执行该组查询.如果其中有任何一条语句因为崩溃或其他原因无 ...

  10. 替换国内yum源以及pip源

    因为一些原因,不论是网络还是啥啥啥的原因,国外的源访问时不时的很慢,这时候我们就可以将国外的源替换为国内源,提高下载速度. yum源替换 环境:centos7(如果你的发行版本不是这个,此方法不保证能 ...