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

Can you solve this equation?

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

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 <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#define eps 1e-8
using namespace std; double fx(double x)
{
return *pow(x,)+*pow(x,)+*x*x+*x+;
} int main()
{
int n,m,i,j;
double y;
double left=,right=,ans;
scanf("%d",&n);
while(n--)
{
scanf("%lf",&y);
left=0.0,right=100.0;
//ans=-100000;
bool flag=true;
while(right-left>eps)
{
double mid=(left+right)/2.0;
if(fx(mid)-y< )
left=mid+eps;
else right=mid-eps;
//if()flag=false;
}
if(y>fx() || y<fx())
printf("No solution!\n");
else
printf("%.4lf\n",left);
} }

hdu 2199 (二分)的更多相关文章

  1. HDU 2199 二分

    我们可以发现这个函数是单增的,那么这样二分就好了. 反思:刚转C++,不会用scanf读入实数.(scanf("%lf",&y)) //By BLADEVIL #inclu ...

  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 4024 二分

    转自:http://www.cnblogs.com/kuangbin/archive/2012/08/23/2653003.html   一种是直接根据公式计算的,另外一种是二分算出来的.两种方法速度 ...

  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. 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. PHP人民币金额数字转中文大写的函数

    <?php header("Content-Type:text/html;charset=utf-8"); error_reporting(2); function cny( ...

  2. ubuntu屏幕分辨率问题

    今天在ubuntu下工作时突然屏幕上下各出现了一个大概2厘米的黑条,感觉屏幕被横向拉长了,莫名其妙,开始以为简单的调整下分辨率就好了,在系统设置显示里面发现分辨率只有两个可选参数,并且对象为未知,由于 ...

  3. 安装新版xampp后apache无法启动提示:Apache Service detected with wrong path解决方案

    我以前安装过xampp,因为学习thingPHP需要升级PHP5.0以上,所以我就卸掉了xampp,从新安装新版本的xampp其中PHP是最新版的,但是安装后启动xampp提示如下:Apache Se ...

  4. PHP处理CSV表格文件的常用操作方法是怎么样呢

    php来说,fgetcsv读入csv表格,返回一个数组,然后foreach输出成HTML的<table>,这步操作几行代码就能实现,非常简单.工作量主要还在于浏览器前端,建议你用jQuer ...

  5. Jetty 嵌入式开发(实例)

    我尝试了jetty几个版本,类的使用有些差异,在此记录下jettyVersion = 9.0.2.v20130417 的部分实例 maven 依赖及配置: <properties> < ...

  6. oracle VS postgresql系列-行列转换

    [需求]例如先有数据为 id | name ------+--------- | lottu | xuan | rax | ak | vincent 现在需要转换为 id | names ------ ...

  7. [HTML]页面间传值的五种方法

    一.QueryString传值:1. 这是最简单的传值方式,但缺点是传的值会显示在浏览器的地址栏中且不能传递对象,只适用于传递简单的且安全性要求不高的整数值,例如: 2. 新建一个WEB项目,添加一个 ...

  8. java中两种单例模式

    //懒汉式(线程不安全) class LazySingleton{ private static LazySingleton singleton; private LazySingleton(){} ...

  9. 棋盘问题 分类: 搜索 POJ 2015-08-09 13:02 4人阅读 评论(0) 收藏

    棋盘问题 Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 28474 Accepted: 14084 Description 在一 ...

  10. Linux内核同步机制

    http://blog.csdn.net/bullbat/article/details/7376424 Linux内核同步控制方法有很多,信号量.锁.原子量.RCU等等,不同的实现方法应用于不同的环 ...