HDU 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): 27728 Accepted Submission(s): 11717
solution between 0 and 100;
Now please try your lucky.
number of test cases. Then T lines follow, each line has a real number Y
(fabs(Y) <= 1e10);
decimal places),which is the solution of the equation,or “No solution!”,if
there is no solution for the equation between 0 and 100.
【题意】
在[0,100]内找一个方程的实数解。
【分析】
求导易得函数单增,只需二分即可。
注意精度!
【代码】
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
using namespace std;
inline int read(){
int x=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
const int N=1e5+5;
int n;double Y;
inline double f(double x){
return 8*x*x*x*x+7*x*x*x+2*x*x+3*x+6;
}
int main(){
for(n=read();n--;){
scanf("%lf",&Y);
if(Y<f(0)||Y>f(100)){puts("No solution!");continue;}
double l=0,r=100,mid,ans;
while(r-l>1e-6){
mid=(l+r)/2.0;
if(Y-f(mid)<=1e-5){
ans=mid;
r=mid;
}
else{
l=mid;
}
}
printf("%.4lf\n",ans);
}
return 0;
}
HDU 2199 Can you solve this equation(二分答案)的更多相关文章
- 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? (二分 水题)
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 ( ...
- 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?(高精度二分)
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?(二分解方程)
传送门: http://acm.hdu.edu.cn/showproblem.php?pid=2199 Can you solve this equation? Time Limit: 2000/10 ...
- 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 ...
- HDU 2199 Can you solve this equation?【二分查找】
解题思路:给出一个方程 8*x^4 + 7*x^3 + 2*x^2 + 3*x + 6 == Y,求方程的解. 首先判断方程是否有解,因为该函数在实数范围内是连续的,所以只需使y的值满足f(0)< ...
- hdu 2199 Can you solve this equation?(二分搜索)
Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ( ...
随机推荐
- [Learn AF3]第四章 App framework组件之Button
Button 组件名称:Button 是否js控件:否 使用说明:如果说panel组件是af3的“核心(heart of the ui)”,那么Button就是af中的五虎上将之 ...
- 图解HTTP学习笔记——确认访问用户身份的认证
前言 认证功能能让Web页面只被有权限的人访问.而认证机制究竟是怎样一个原理呢?通过今天的学习能对这个有个大致的了解. 正文 什么是认证 计算机无法判断对方的身份,需要客户端自报家门. 服务端为确认客 ...
- UGUI表情系统解决方案
参考链接: https://blog.uwa4d.com/archives/Sparkle_UGUI.html http://tech.seasungame.com/blog/index.php/20 ...
- proto序列化
proto序列化和反序列化类 序列化是将我们的Protobuf类对象转换成字节数组的方法,网络底层我们从服务器获取到的是字节数组,反序列化是将字节转成proto类对象的方法 public class ...
- python 字符串格式化,使用f前缀
格式化一般用%,但后来推荐用format format有进步,可以用索引或者名字,但仍然没有很方便和快捷 # logger.debug('{} {} {} {} {} {}'.format(metho ...
- An internal error occurred during: "Launching xxx on WebLogic10.x".
An internal error occurred during: "Launching xxx on WebLogic10.x". java.lang.NullPointerE ...
- 【Java-Web】初始化加载Serlvet工程后-HttpServlet报错
1.Tomcat配置 2.Java Build Path
- 【GIS】Cesium回到初始位置
var boundingSphere = new Cesium.BoundingSphere(Cesium.Cartesian3.fromDegrees(116.4, 39.9, 100), 15 ...
- Splash scroll_position 属性
scroll_position属性用于控制页面上下或左右滚动,如下,表示控制页面向下滚动 400 像素值并返回结果图, function main(splash, args) assert(splas ...
- 集群瓶颈为什么是磁盘io
阅读本文思考: 1.对磁盘IO了解多少 2.为什么是磁盘IO是瓶颈,有没有自己的答案 想了解磁盘io可以查看此帖:集群瓶颈:磁盘IO必读 (磁盘IO:磁盘输出输出) 集群的瓶颈提出多种看法,其中网络和 ...