Problem Description

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

2
100
-4

Sample Output

1.6152
No solution!

Author

Redow


思路

这个问题可以用二分法解决,因为给定的函数是单调的,所以可以根据要求的精度不断二分找答案

详见代码

代码

#include<bits/stdc++.h>
using namespace std; double f(double x)
{
return 8*x*x*x*x + 7*x*x*x + 2*x*x + 3*x + 6 ;
} int main()
{
int n;
cin >> n;
while(n--)
{
double t;
cin >> t;
double l = 0, r = 100.0;
if(t<f(0) || t>f(100.0))
{
cout << "No solution!\n";
continue;
}//因为函数单调,所以可以这么判断
double mid;
while(r-l>1e-8)
{
mid = (l+r)/2;
double ans = f(mid);
if(ans>t)
r = mid;
if(ans<t)
l = mid;
}
printf("%.4lf\n",l);
}
return 0;
}

Hdoj 2199.Can you solve this equation? 题解的更多相关文章

  1. hdoj 2199 Can you solve this equation?【浮点型数据二分】

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

  2. hdoj 2199 Can you solve this equation? 【二分枚举】

    题意:给出一个数让你求出等于这个数的x 策略:如题. 由于整个式子是单调递增的.所以能够用二分. 要注意到精度. 代码: #include <stdio.h> #include <s ...

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

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

  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?(二分搜索)

    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. 实现h5中radio单击取消与选中

    <input type = "radio" id = "raid" name = "raname" checked = 'checke ...

  2. 【kindle笔记】之 《鬼吹灯》-9-20

    [kindle笔记]读书记录-总 9-20 日常吐槽 连着几天,基本是一口气读完了鬼吹灯. 想来,也算是阴差阳错了.本来是想看盗墓的,读了几页开头,心想坏了,拷贝错了,这是鬼吹灯-- 讲真的,每每读小 ...

  3. VMware虚拟机中常见的问题汇总

    在使用虚拟机进行开发工作的时候,经常会遇到各种各样的问题, 总结再次, 防微杜渐 1. wget: unable to resolve host address的解决方法 原因分析: DNS域名解析的 ...

  4. Laravel 核心--Facades 门面

    Laravel 核心--Facades 门面 伊Summer 关注  0.1 2017.08.12 19:07* 字数 2017 阅读 1089评论 0喜欢 5 介绍 Facades 为应用的 IoC ...

  5. Java中有关Null的9件事(转)

    对于Java程序员来说,null是令人头痛的东西.时常会受到空指针异常(NPE)的骚扰.连Java的发明者都承认这是他的一项巨大失误.Java为什么要保留null呢?null出现有一段时间了,并且我认 ...

  6. [转帖]SAP一句话入门:Finacial & Controlling Accounting

    SAP一句话入门:Finacial & Controlling Accounting http://blog.vsharing.com/MilesForce/A621147.html 财务,财 ...

  7. jQuery ajax解析xml文件demo

    解析xml文件,然后将城市列表还原到下拉列表框中:当选择下拉列表框时,在对应的文本框中显示该城市信息. 前端代码: <!doctype html> <html> <hea ...

  8. 免费苹果账号(apple id)申请ios证书p12真机调试

    HBuilder可以直接打包越狱版的ipa包,但需要越狱手机才能安装,如果需要安装到没越狱的手机安装,需要自己申请ios证书打包. 一般是需要一个付费了的苹果开发者账号才能申请ios证书打包. 这里介 ...

  9. HTML4到HTML5

    第一步: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0.1//EN" "http://www.w3.org/TR/html ...

  10. linux audit (9)--生成audit报表

    aureport这个命令可以生成一个总结性的柱状图报表,默认情况下,在/var/log/audit目录下的所有日志文件都会生成一个报表,也可以使用如下命令来指定一个不同的文件,aureport opt ...