链接:

http://acm.hdu.edu.cn/showproblem.php?pid=2199

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

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!

代码:

#include <iostream>
#include <cstdio>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <queue>
#include <algorithm>
using namespace std; const int oo = 0x3f3f3f3f;
const int N = ; int main()
{
int t;
scanf("%d", &t);
while(t--)
{
int flag=;
double y, l=, r=, x;
scanf("%lf", &y); double m = **** + *** + ** + * + ; if(fabs(y-m)<0.0001)
{
printf("100.0000\n");
continue;
} while(l<r)
{
x = (l+r)/;
m = *x*x*x*x + *x*x*x + *x*x + *x + ; if(fabs(m-y)<0.0001)
{
flag = ;
break;
}
else if(m>y)
r = x;
else if(m<y)
l = x;
} if(flag)
printf("%.4f\n", x);
else
printf("No solution!\n");
}
return ;
}

(二分搜索)Can you solve this equation? -- hdu -- 2199的更多相关文章

  1. C - Can you solve this equation? HDU - 2199(二分水题)

    Now,given the equation 8x^4 + 7x^3 + 2x^2 + 3x + 6 == Y,can you find its solution between 0 and 100; ...

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

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

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

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

  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. C Socket编程之Connect超时 (转)

    网络编程中socket的分量我想大家都很清楚了,socket也就是套接口,在套接口编程中,提到超时的概念,我们一下子就能想到3个:发送超时,接收超时,以及select超时(注:select函数并不是只 ...

  2. WebKit的已实施srcset图像响应属性

    WebKit已经发布了一些官方新闻,终于落实srcset的属性.作为W3C的响应图像社区组的主席,我一直希望这一刻到来有一段时间了.所以,对所有参与方是个好消息,用户浏览网页时的体验是最重要的. 所有 ...

  3. hadoop启动时,报ssh: Could not resolve hostname xxx: Name or service not known

    本文转载自:http://blog.csdn.net/wodewutai17quiet/article/details/76795951 问题:hadoop启动时,报ssh: Could not re ...

  4. struts2学习(2)struts2核心知识

    一.Struts2 get/set 自动获取/设置数据 根据上一章.中的源码继续. HelloWorldAction.java中private String name,自动获取/设置name: pac ...

  5. [saiku] saiku-添加数据源以及保证数据源的一致性

    采用任何一种添加数据源的方式都不能保证数据源的一致和完整,所以需要两种结合来管理数据源 1.通过saiku的管理台添加数据源 ① 第一种方式:schema和ds都在管理台添加 1)上传schema文件 ...

  6. 告诉你C盘里的每个文件夹都是干什么用的 ! ! !

      Documents and Settings是什么文件? 答案: 是系统用户设置文件夹,包括各个用户的文档.收藏夹.上网浏览信息.配置文件等. 补:这里面的东西不要随便删除,这保存着所有用户的文档 ...

  7. python爬虫----基本操作

    一.爬虫基本操作 有些网站和其他网站是有关系(链接),全球的网站就相当于一个蜘蛛网,我们放一只蜘蛛在上面爬,一定能够把网爬个遍.那么如果我们要爬取互联网上内容我们就相当于放一只蜘蛛在上面. 爬虫分为 ...

  8. #region 常量和静态变量静态类readonly

    #region 常量和静态变量静态类readonly //---------------------------------------------------------------------- ...

  9. c语言实现常见字符串函数strchr strstr strcmp atoi itoi(字符串换成整数)

    好久没有更新博客了,刚刚出炉练练手的程序如下,很简单,没有考虑过多复杂的东西,有好的想法,欢迎指教: 字符查找函数: char *my_strchr(const char *s,int c) { ch ...

  10. android在开发过程中的数据库存储位置

    1