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 ( ...
随机推荐
- Mac下配置Hive环境
在配置Hive环境之前,需要Hadoop环境. 安装Hive 点击下载 下载结束后,会有一个.tar文件,使用以下命令解压该文件. tar -zxvf 要解压的tar包 解压完成后如下 修改Hive配 ...
- Python的hasattr() getattr() setattr() 函数使用方法详解--转载
hasattr(object, name)判断一个对象里面是否有name属性或者name方法,返回BOOL值,有name特性返回True, 否则返回False.需要注意的是name要用括号括起来 1 ...
- python 判断是否是元音字母
def is_vowel(char): all_vowels = 'aeiou' return char in all_vowels print(is_vowel('c')) print(is_vow ...
- maven3常用命令、java项目搭建、web项目搭建
------------------------------maven3常用命令--------------------------- 1.常用命令 1)创建一个Project mvn archety ...
- ng-disabled 指令
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script sr ...
- 导出csv文件,导出axlsx文件。gem 'Axlsx-Rails' (470🌟);导入csv文件。
汇出 CSV 档案 需求:后台可以汇出报名资料 有时候后台功能做再多,也不如 Microsoft Excel 或 Apple Numbers 试算表软件提供的分析功能,这时候如果有汇出功能,就可以很方 ...
- sql语句in
在今天之前sql一直用in语句,知道今天遇到一张数据量很大的表查了三分钟才查出来,这才意识到数据库优化有多重要.作为一名开发人员,首先从优化sql语句开始. 之前用in写sql是这样的 select ...
- 【hive】数据仓库层次设计
转载 https://www.jianshu.com/p/849db358ec61
- PHP:第五章——字符串的分割与替换
<?php header("Content-Type:text/html;charset=utf-8"); //字符串的截取与分割 //1.字符串截取类函数 //1)trim ...
- 安装Ubuntu之后的配置
经常装系统或者给人装系统,这些配置还是记一下,方便恢复到以前的环境 删除libreoffice sudo apt-get remove libreoffice-common 删除Amazon的链接 s ...