Can you solve this equation?

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 7493    Accepted Submission(s): 3484

Problem Description
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.
 
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
2
100
-4
 
Sample Output
1.6152
No solution!
 
Author
Redow
 
Recommend
lcy   |   We have carefully selected several similar problems for you:  2899 2289 2298 3400 1969 

 
  二分搜索
  先要判断方程的单调性。可用 cal()<=y && y<=cal() 判断。
  二分法不断提高精度,最后到某个精度位置输出就是正确答案。
  注意题目给出的第一组测试数据是错的,AC代码出来的结果是1.6151,而不是1.6152。
  代码:
 #include <iostream>
#include <cmath>
#include <iomanip>
using namespace std; double cal(double x)
{
return *pow(x,) + *pow(x,) + *pow(x,) + *x + ;
}
double GetAns(double y)
{
double a=,b=;
while(b-a>1e-){
double mid=(a+b)/;
cal(mid)<y?a=mid:b=mid;
}
return (a+b)/;
}
int main()
{
int T;
cin>>T;
while(T--){
double y;
cin>>y;
if(cal()<=y && y<=cal()){
cout<<setiosflags(ios::fixed)<<setprecision();
cout<<GetAns(y)<<endl;
}
else
cout<<"No solution!"<<endl;
}
return ;
}

Freecode : www.cnblogs.com/yym2013

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?(二分精度)

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

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

  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. ECSHOP手机号码或邮箱用户名都可以登录方法

    ECSHOP手机号码或邮箱用户名都可以登录方法 ECSHOP教程/ ecshop教程网(www.ecshop119.com) 2013-06-30   有不少人都在找支持ECShop用户名.邮箱或手号 ...

  2. JavaScript事件

    关于JavaScript事件讲解得很全面的一篇文章:http://www.cnblogs.com/tugenhua0707/p/4501843.html 如下代码需要注意的一点是,除了getEvent ...

  3. 标题右边10px位置紧跟发布时间

    一个ul列表,拥有若干li,内容是新闻标题,标题右边10px位置紧跟发布时间,当标题过长需要控制标题width,需要兼容ie6,不能用max-width h4{font-size:14px;heigh ...

  4. WAF与IPS的区别总结

    谁是最佳选择? Web应用防护无疑是一个热门话题.由于技术的发展成熟和人们对便利性的期望越来越高,Web应用成为主流的业务系统载体.在Web上“安家”的关键业务系统中蕴藏的数据价值引起攻击者的青睐,网 ...

  5. Windows 下配置使用MemCached(转载)

    工具: memcached-1.2.6-win32-bin.zip     MemCached服务端程序(for win) Memcached Manager             win下的Mem ...

  6. iOS开发摇动手势实现详解

    1.当设备摇动时,系统会算出加速计的值,并告知是否发生了摇动手势.系统只会运动开始和结束时通知你,并不会在运动发生的整个过程中始终向你报告每一次运动.例如,你快速摇动设备三次,那只会收到一个摇动事件. ...

  7. 如何设置通过ip访问数据库

    文章转自:http://blog.163.com/wz_pk007/blog/static/17062705020119242440713/ 问题:mysql只能用localhost或127.0.0. ...

  8. characterCustomezition的资源打包代码分析

    using System.Collections.Generic; using System.IO; using UnityEditor; using UnityEngine; class Creat ...

  9. IOS 使用横屏

    http://lizhuang.iteye.com/blog/1684881 在iPad应用开发时如何让设备只支持横屏(landscape)模式,我做了多次尝试,并没有发现比较简捷的设置方法.我尝试了 ...

  10. js 中数组或者对象的深拷贝和浅拷贝

    浅拷贝 : 就是两个js 对象指向同一块内存地址,所以当obj1 ,obj2指向obj3的时候,一旦其中一个改变,其他的便会改变! 深拷贝:就是重新复制一块内存,这样就不会互相影响. 有些时候我们定义 ...