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

  1. 2
  2. 100
  3. -4

Sample Output

  1. 1.6152
  2. No solution!
  3.  
  4. 这种题一般都很注重精度的,可以拿两个端点来做验证,6的时候应该为0.0000,807020306的时候应该为100.0000
    其中while(ri-le<=0.000000001)这里的0尽量多一点,而判断的时候的0的个数要看情况,有些当满足
  1. ri-le<=0.000000001时,说不定判断还不满足。
  1. #include <iostream>
  2. #include <stack>
  3. #include <string.h>
  4. #include <stdio.h>
  5. #include<queue>
  6. #include<algorithm>
  7. #define ll long long
  8. using namespace std;
  9. int main()
  10. {
  11. int t;
  12. cin>>t;
  13. while(t--)
  14. {
  15. double y;
  16. cin>>y;
  17. double le,ri,mid;
  18. le=;ri=;
  19. bool f=;
  20. while(ri-le>=0.00000000000001)
  21. {
  22. mid=(le+ri)/;
  23. //cout<<8*mid*mid*mid*mid+7*mid*mid*mid+2*mid*mid+3*mid+6-y<<endl;
  24. 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>=)
  25. {
  26. f=;
  27. break;
  28. }
  29. else if(*mid*mid*mid*mid+*mid*mid*mid+*mid*mid+*mid+-y<)
  30. {
  31. le=mid;
  32. }
  33. else
  34. ri=mid;
  35. }
  36. if(f)
  37. printf("%.4lf\n",mid);
  38. else
  39. printf("No solution!\n");
  40. }
  41. return ;
  42. }
  1.  

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. Mac下配置Hive环境

    在配置Hive环境之前,需要Hadoop环境. 安装Hive 点击下载 下载结束后,会有一个.tar文件,使用以下命令解压该文件. tar -zxvf 要解压的tar包 解压完成后如下 修改Hive配 ...

  2. Python的hasattr() getattr() setattr() 函数使用方法详解--转载

    hasattr(object, name)判断一个对象里面是否有name属性或者name方法,返回BOOL值,有name特性返回True, 否则返回False.需要注意的是name要用括号括起来 1 ...

  3. python 判断是否是元音字母

    def is_vowel(char): all_vowels = 'aeiou' return char in all_vowels print(is_vowel('c')) print(is_vow ...

  4. maven3常用命令、java项目搭建、web项目搭建

    ------------------------------maven3常用命令--------------------------- 1.常用命令 1)创建一个Project mvn archety ...

  5. ng-disabled 指令

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script sr ...

  6. 导出csv文件,导出axlsx文件。gem 'Axlsx-Rails' (470🌟);导入csv文件。

    汇出 CSV 档案 需求:后台可以汇出报名资料 有时候后台功能做再多,也不如 Microsoft Excel 或 Apple Numbers 试算表软件提供的分析功能,这时候如果有汇出功能,就可以很方 ...

  7. sql语句in

    在今天之前sql一直用in语句,知道今天遇到一张数据量很大的表查了三分钟才查出来,这才意识到数据库优化有多重要.作为一名开发人员,首先从优化sql语句开始. 之前用in写sql是这样的 select ...

  8. 【hive】数据仓库层次设计

    转载 https://www.jianshu.com/p/849db358ec61

  9. PHP:第五章——字符串的分割与替换

    <?php header("Content-Type:text/html;charset=utf-8"); //字符串的截取与分割 //1.字符串截取类函数 //1)trim ...

  10. 安装Ubuntu之后的配置

    经常装系统或者给人装系统,这些配置还是记一下,方便恢复到以前的环境 删除libreoffice sudo apt-get remove libreoffice-common 删除Amazon的链接 s ...