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 ( ...
随机推荐
- Jwt访问api提示401错误 Authorization has been denied for this request
教程 http://bitoftech.net/2015/02/16/implement-oauth-json-web-tokens-authentication-in-asp-net-web-ap ...
- http://www.artrobot.com/北京钢铁侠
http://www.artrobot.com/ 钢铁侠ROS智能机器人 钢铁侠ROS智能机器人 型号 ARTrobot-ROS 产品图片: 产品概述: ARTrobot-ROS全开放机器人套件服 ...
- FreeSouth的学习osg小贴士
http://www.osgchina.org/index.php?option=com_content&view=article&id=150&catid=91&It ...
- c++指向指针的指针与 c++指针作为函数参数传递问题
一直搞不明白,c++中指针到底是个啥东西,今天遇到到c++,指向指针的指针的问题,突然有点开窍了. 举个例子: int main(int argc, char** argv){ int a[5]={1 ...
- Android之微信开放平台创建应用
微信开放平台网站:https://open.weixin.qq.com 1:登录之后(未登录就注册),点击移动应用开发进入 点击创建应用之后,进入填写对应信息. 接下来,填写平台信息. 应用签名获取方 ...
- 唯一索引 && 主键索引
唯一索引唯一索引不允许两行具有相同的索引值. 如果现有数据中存在重复的键值,则大多数数据库都不允许将新创建的唯一索引与表一起保存. 当新数据将使表中的键值重复时,数据库也拒绝接受此数据.例如,如果在 ...
- linux hosts.equiv设置解析
hosts.equiv文件的用途与格式 一. hosts.equiv 文件的用途 /etc/hosts.equiv 和 $HOME/.rhosts 定义了哪些计算机和用户可以不用提供口令就在本地计算机 ...
- 005PHP文件处理——目录操作,统计大小 filesize unlink
<?php /* 目录操作,统计大小 filesize unlink * */ $dir = dir("."); while (($file = $dir->read( ...
- Python - learn note(1)
1. 下载安装Python 2.7(为了向下兼容以前的版本), Python 3.5(VS2015不支持配置3.6的环境) 教程 需要使用VS2015进行开发,必须勾选上后面两项: 2. VS2015 ...
- MissingNumber缺失的数字,FirstMissingPositive第一个缺失的正数
MissingNumber问题描述:给定一个数组,数组数字范围是0-n,找到缺失的数字.例如nums={0,1,3},return2. 算法分析:第一种方法,对数组进行排序,然后找到和下标不一致的数字 ...