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 ( ...
随机推荐
- C# CRC校验的一点感悟
今天在鼓捣一个手持操作器的时候,遇到一点问题,记录一下今天的经验包 由于之前公司产品在校验时基本上都是和校验,今天在准备用C#模拟一个古董操作器的时候,却遇到一个问题,模拟器发出的数据,主板一律不回复 ...
- gulp之css,js压缩合并加密替换
为了防止客户端的静态资源缓存,我们需要每次更新css或js的时候,通过md5或时间戳等方式重新命名静态资源.让客户端可以重新请求资源,而不是从缓存里取.然后html模板里的src也要做相应的修改.当然 ...
- 菜鸟日记之JSP1
JSP全名为Java Server Pages,中文名叫java服务器页面,其根本是一个简化的Servlet设计,它 是由Sun Microsyste ...
- jquery 幻灯片
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- OSI参考模型 VS TCP/IP参考模
OSI参考模型 VS TCP/IP参考模 TCP/IP各层对应的协议 TCP/IP的层 对应的TCP/IP协议 ...
- 横向浅谈移动技术------( 原生,混合,web --- 谁能问鼎移动开发的明天)
目前移动互联网基本采用了NativeApp.WebApp.HybridApp三种开发模式,很难说这三种模式那种更优越,目前的情况可以说是三分天下吧,不同的开发者可以根据自己的实际情况选择不同的开发模式 ...
- [CF Round #294 div2] D. A and B and Interesting Substrings 【Map】
题目链接:D. A and B and Interesting Substrings 题目大意 给定26个小写字母的权值,一共26个整数(有正有负). 给定一个小写字母组成的字符串(长度10^5),求 ...
- nodejs 机制
http://news.cnblogs.com/n/190903/ http://www.ruanyifeng.com/blog/2013/10/event_loop.html https://www ...
- PHP 之 Laravel 框架安装及相关开源软件
Laravel 被称为简洁.优雅的PHP开发框架,但第一次接触此框架的人有不少都卡在了安装上,其实在 Linux 下只需要很简单的几步就可以搞定,这里我们以 CentOS 下 PHP + Nginx ...
- C/C++ 开源库及示例代码
C/C++ 开源库及示例代码 Table of Contents 说明 1 综合性的库 2 数据结构 & 算法 2.1 容器 2.1.1 标准容器 2.1.2 Lockfree 的容器 2.1 ...