Now,given the equation 8x^4 + 7x^3 + 2x^2 + 3x + 6 == Y,can you

find its solution between 0 and 100; Now please try your lucky. Input

The 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); Output For 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
  4. Sample Output
  5. 1.6152
  6. No solution!
  1. #include<iostream>
  2. #include<algorithm>
  3. #include<cstdio>
  4. #include<cmath>
  5. using namespace std;
  6. #define ll long long
  7. #define db double
  8. const int Len = 1e5+10;
  9. db Cal(db m)
  10. {
  11. return 8 * pow(m, 4) + 7 * pow(m, 3) + 2 * pow(m, 2) + 3 * m + 6;
  12. }
  13. int main()
  14. {
  15. //freopen("A.txt","r",stdin);
  16. int t;
  17. cin >> t;
  18. while(t --)
  19. {
  20. int n;
  21. scanf("%d", &n);
  22. db l = 0, r = 100;
  23. if(Cal(0) > n || Cal(100) < n)
  24. cout << "No solution!\n";
  25. else
  26. {
  27. db m;
  28. while(r - l >= 1e-10)
  29. {
  30. m = (l + r)/2;
  31. if(Cal(m) > n)
  32. r = m;
  33. else
  34. l = m;
  35. }
  36. printf("%.4lf\n", m);
  37. }
  38. }
  39. return 0;
  40. }

C - Can you solve this equation? HDU - 2199(二分水题)的更多相关文章

  1. (二分搜索)Can you solve this equation? -- hdu -- 2199

    链接: http://acm.hdu.edu.cn/showproblem.php?pid=2199 Time Limit: 2000/1000 MS (Java/Others)    Memory ...

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

  3. HDU 2199 Can you solve this equation?(二分精度)

    HDU 2199 Can you solve this equation?     Now,given the equation 8*x^4 + 7*x^3 + 2*x^2 + 3*x + 6 == ...

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

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

  6. hdu 2199 Can you solve this equation?(二分搜索)

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

  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? (二分 水题)

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

  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. Java 8 Optional 良心指南,建议收藏

    想学习,永远都不晚,尤其是针对 Java 8 里面的好东西,Optional 就是其中之一,该类提供了一种用于表示可选值而非空引用的类级别解决方案.作为一名 Java 程序员,我真的是烦透了 Null ...

  2. C++ 结构体sturct练习

    #define _CRT_SECURE_NO_WARNINGS #include <stdio.h> struct Student { ];// 姓名 int id; //id int a ...

  3. mycli初体验

    一.安装 pip install mycli 二.使用 mycli --help 三.特点 语法不全,高亮等

  4. Crypto++ 无法解析的外部符号 CryptoPP::AssignIntToInteger

    预处理器定义中添加:CRYPTOPP_NO_ASSIGN_TO_INTEGER 方案出自:https://github.com/weidai11/cryptopp/issues/389

  5. Python习题集(十三)

    每天一习题,提升Python不是问题!!有更简洁的写法请评论告知我! https://www.cnblogs.com/poloyy/category/1676599.html 题目 写一个函数,该函数 ...

  6. C#基础--迭代器初识

    foreach语句是枚举器(enumerator)的消费者,而迭代器(iterator)是枚举器的产生者. 迭代器模式能提供一种顺序访问一个集合内部的元素,而又不会暴露其内部的方法.当然其缺点就是用f ...

  7. MassDNS:跨域DNS枚举工具

    MassDNS:跨域DNS枚举工具 simeon 原文地址:http://offsecbyautomation.com/Use-MassDNS/ 工具地址:https://github.com/ble ...

  8. MySQL学习(3)

    一 SQL语句 1. 数据库级别(*) 显示全部数据库:show databases; 创建数据库:create database '数据库名字’; 使用数据库:use '数据库名字'; 删除数据库: ...

  9. Visual Studio2019+OpenCV3.4.9环境搭建

    让人头疼的vs2019+opencv环境配置 准备: visual studio2019: opencv 3.4.9: 耐心: 说明:vs2019属性管理器没有Microsoft.Cpp.x64.us ...

  10. [字典树,trie树] 树之呼吸-肆之型-前缀统计

    D.树之呼吸-肆之型-前缀统计 Time Limit: 1000 MS Memory Limit: 65536 K Total Submit: 59 (8 users) Total Accepted: ...