Can you solve this equation?

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

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>
double f(double v)//用来计算方程结果(即y的值)
{
return 8*v*v*v*v+7*v*v*v+2*v*v+3*v+6;
}
int main()
{
int t;
double y,l,r,mid;
scanf("%d",&t);
while(t--)
{
scanf("%lf",&y);
if(y<f(0)||y>f(100))
{
printf("No solution!\n");
continue;
}
l=0;r=100;mid=0;
while((r-l) > 1e-10)//题目要求精度为小数点后四位,最好把精度调高
{
mid=(l+r)/2;//每次折半取x的范围
if(f(mid) < y)
l=mid;
else
r=mid;
}
printf("%.4lf\n",mid);
}
}

  

hdoj 2199 Can you solve this equation?【浮点型数据二分】的更多相关文章

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

  2. Hdoj 2199.Can you solve this equation? 题解

    Problem Description Now,given the equation 8x^4 + 7x^3 + 2x^2 + 3x + 6 == Y,can you find its solutio ...

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

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

  4. HDU 2199 Can you solve this equation? 【浮点数二分求方程解】

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

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

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

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

  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. 协程的作用 Python

    1.协程的含义和实现 协程是单进程单线程的超越函数的调度机制,它通过一定的调度手段进行调度. (Python使用generator机制,greenlet使用汇编控制对程序指向来实现). 2.协程有什么 ...

  2. async: false的应用.

    目的: 手机webview中, js ajax请求, success后, 进行window.open 操作 问题: 在Android, IOS均不能执行window.open 解决办法: 设置ajax ...

  3. LINUX 压缩目录成一个压缩文件

    #!/bin/bash file =$(date +%y%m%d%H%M)logfile=/home/目录名/backup/file.log echo "------"$(date ...

  4. ajax只是一个称呼

    记得刚入行的时候,看到ajax,即异步的javascript和xml这样一个概念,一点感觉都没有.参加工作前的第一轮面试,被问到有没有自己实现过ajax,我觉得自己实现肯定很复杂吧. 从名字理解 从名 ...

  5. 获取Ip 的地域等信息接口-实例

    今天项目要用到 查询访问网站用户的IP 然后网上查询了 资料还很多 不过有些已经失效了 在这总结下 腾讯,pconline 的API已经失效 不能使用 淘宝的IP接口地址: http://ip.tao ...

  6. boost之algorithm/string

    头文件: #include<iostream>#include <boost/algorithm/string.hpp>using namespace std;using na ...

  7. 【C语言】中的版本规范(C89 C99等)

    C语言中的版本 一.相关基础知识 ISO:国际标准化组织(International Organization for Standardization,ISO)简称ISO,是一个全球性的非政府组织,是 ...

  8. 同步的HTTP请求

    代码: #import <Foundation/Foundation.h> void request(NSString *urlString) { NSLog(@"BEGIN&q ...

  9. IIs工作原理

    http://www.cnblogs.com/szhy222/archive/2008/07/14/1242576.html 问题: HTTP.SYS 的内置驱动程序 IIS 工作者进程

  10. Data guard RAC配置【二】

    2. 利用duplicate配置容灾端 1.配置容灾端oracle用户的环境变量,这里以192.166.1.61为例. export ORACLE_BASE=/opt/oracle export OR ...