hdoj 2199 Can you solve this equation?【浮点型数据二分】
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
== Y,can you find its solution between 0 and 100;
Now please try your
lucky.
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);
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.
#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?【浮点型数据二分】的更多相关文章
- 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 ...
- 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 ...
- hdoj 2199 Can you solve this equation? 【二分枚举】
题意:给出一个数让你求出等于这个数的x 策略:如题. 由于整个式子是单调递增的.所以能够用二分. 要注意到精度. 代码: #include <stdio.h> #include <s ...
- 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; ...
- 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 ...
- 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 == ...
- 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 ...
- hdu 2199 Can you solve this equation?(二分搜索)
Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ( ...
- hdu 2199:Can you solve this equation?(二分搜索)
Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ( ...
随机推荐
- 【转】发布iOS应用程序到苹果APP STORE完整流程
原文: http://www.cnblogs.com/JuneWang/p/3850859.html 可以为每个app上传5张截图,虽然至少需要上传一张,可能很少有人会只上传一张图片.另外,你还需要分 ...
- 0-C相关01:NSlog函数介绍。
NSlog()函数介绍: 首先:NSlog()函数是cocoa的框架中提供的一个方法: 下图中最上方是它在Xcode中的路径: : 同样都是输出函数.下边我们来看一下,在O-C中NSlog()和在 ...
- 5 DML语言
body { font-family: "Microsoft YaHei UI","Microsoft YaHei",SimSun,"Segoe UI ...
- WPF 保存文件
private void button2_Click(object sender, RoutedEventArgs e) { var saveFileDialog1 = new SaveFileDia ...
- 配置处理结果result
Action处理完用户请求后返回一个字符串,整个字符串就是一个逻辑视图名. 除此之外,struts2还支持多种结果映射,struts2将结果转为实际资源时,不仅可以是JSP视图资源,也可以是FreeM ...
- #Leet Code# Root to leaf
语言:Python 描述:使用递归实现 def getList(self, node): if node is None: return [] if node.left is None and nod ...
- 一个简单的webservice调用
我们先创建一个简单空web应用程序 然后添加新建项目 //我们创建一个peson对象,产生数据标识返回 using System; using System.Collections.Generic; ...
- url、base64 编码规则
UrlEncode 相关: URI所允许的字符分作保留与未保留. 保留字符是那些具有特殊含义的字符. 例如, 斜线字符用于URL (或者更一般的, URI)不同部分的分界符. 未保留字符没有这些特殊含 ...
- 自动发布工具版本从python2升级成python3后遇到的种种问题(涉及paramiko,Crypto,zipfile等等)
从在公司实习到正式入职,一直还在被同事使用的是我写的一个自动发布工具.该工具的主要功能是:开发人员给出需要更新的代码包(zip格式),测试人员将该代码包部署到测服,这些代码包和JIRA数据库里的项目信 ...
- GHOST备份
整理日: 2015年2月16日 GHOST Disk2GHO STEP01 STEP02 STEP03 STEP04 STEP05 STEP06 STEP07 STEP08 STEP09 STEP10