链接:

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

    基本环境为:Centos6.6+Apache2.2.15+php5.3.3+Mysql5.1.73 开始下载了网站上最新版本myPhpAdmin4.3.8安装后打开浏览器为空白页,后百度后都讲是与PH ...

  2. PHP框架(如:laravel、yii2、thinkPHP5)中统一异常处理及统一日志打印

    背景: 现在写接口服务应用有一个很通用的需求,想通过日志.或者监控的形式监测的接口的运行情况,比如耗时.请求参数.响应结果.和前端联调接口时或者排查线上问题时日志必不可少,特别是现场日志. 应用运行时 ...

  3. 汇编_指令_SUB

    SUB是减法运算. 比如mov ax,2mov bx,1sub ax,bx 其中sub ax,bx就是ax中的值减bx中的值,等于1,然后把结果,也就是1,放入ax中.

  4. 文件计数--file_count.sh

    countFiles(){ path=$1 pathName=`ls $path` sum=0 for i in $pathName do num=`ls $path$i |wc -l` sum=$[ ...

  5. 解决Linux下MySQL登录ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using passwor)问题

    两种方案: 一: 1.修改mysql配置文件:vim /etc/my.cnf 2.找到[mysqld]下添加 skip-grant-tables 配置 3.重启服务service mysqld res ...

  6. hex文件和bin文件区别

    HEX文件和BIN文件是我们经常碰到的2种文件格式.因为自己也是新手,所以一直对这两个文件懵懵懂懂,不甚了解,最近在做STM32单片机的IAP更新,其中要考虑HEX文件和BIN文件,所以需要学习下这两 ...

  7. 使用TensorFlow识别照片中的物体

    1.环境ubuntu14.04.5 安装TensorFlow 官方文档:https://www.tensorflow.org/install/install_linux sudo pip instal ...

  8. SpringBoot Session 管理及集群管理

    1.配置session的超时时间 : 在application.prooperties中 server.session.timeout = 600       //以秒为单位,默认最少一分钟 2.配置 ...

  9. TNS:no listener error in Oracle XE after changing computer name

    This morning at work when trying to log on to my computer I noticed not my username on login screen ...

  10. ubuntu 安装google输入法

    第五步:通常情况下,IBus图标(一个小键盘)会出现在桌面右上角的任务栏中.有时候这个图标会自行消失,可使用以下命令,找回消失的IBus图标: ibus-daemon -drx   不建议用googl ...