HDU2899 Strange fuction 【二分】
Strange fuction
F(x) = 6 * x^7+8*x^6+7*x^3+5*x^2-y*x (0 <= x <=100)
Can you find the minimum value when x is between 0 and 100.
2
100
200
-74.4291
-178.8534
#include <stdio.h>
#include <math.h>
double y, ans; double f(double x){
return 6 * pow(x, 7) + 8 * pow(x, 6) +
7 * pow(x, 3) + 5 * x * x - y * x;
} double ff(double x){ //求导
return 42 * pow(x, 6) + 48 * pow(x, 5)
+ 21 * x * x + 10 * x - y;
} int main(){
int n;
scanf("%d", &n);
while(n--){
scanf("%lf", &y);
if(ff(0) >= 0) ans = f(0);
else if(ff(100) <= 0) ans = f(100);
else{
double left = 0, right = 100, mid;
while(left + 1e-8 < right){
mid = (left + right) / 2;
if(ff(mid) > 0) right = mid;
else if(ff(mid) < 0) left = mid;
else break;
}
ans = f(mid);
}
printf("%.4lf\n", ans);
}
return 0;
}
HDU2899 Strange fuction 【二分】的更多相关文章
- HDU 2899 Strange fuction [二分]
1.题意:给一个函数F(X)的表达式,求其最值,自变量定义域为0到100 2.分析:写出题面函数的导函数的表达式,二分求导函数的零点,对应的就是极值点 3.代码: # include <iost ...
- hdu2899 Strange fuction
在区间(0,100).在恒大二阶导数0.f(x)有极小值.用的最低要求的一阶导数值点: #include<math.h> #include<stdio.h> #include& ...
- ACM : HDU 2899 Strange fuction 解题报告 -二分、三分
Strange fuction Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Tot ...
- hdoj 2899 Strange fuction【二分求解方程】
Strange fuction Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)T ...
- 【精度问题】【HDU2899】Strange fuction
Strange fuction Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- Strange fuction hdu 2899
Strange fuction Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)T ...
- hdu 2899 Strange fuction
http://acm.hdu.edu.cn/showproblem.php?pid=2899 Strange fuction Time Limit: 2000/1000 MS (Java/Others ...
- Strange fuction
Strange fuction Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Tot ...
- hdu 2899 Strange fuction (二分法)
Strange fuction Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)T ...
随机推荐
- jenkinsfile or pipline 实现微服务自动发布回滚流程
1 #!/usr/bin/env groovy Jenkinsfile node { //服务名称 def service_name = "**" //包名 def service ...
- 元素属性的添加删除(原生js)
添加属性 odiv.setAttribute("title","hello div!"); odiv.setAttribute("class" ...
- JS——轮播图简单版
1.小图标版本 <!DOCTYPE html> <html lang="en"> <head> <meta charset="U ...
- Python 时间处理---------笔记
时区处理&格式化 import pytz from datetime import datetime # 设置时区 timezone = pytz.timezone('Asia/Shangha ...
- [转]linux实时查看更新日志命令
很多时候在调试生成或正式平台服务器的时候想查看实时的日志输出,在Linux中可以使用tail 或 watch来实现. 比如我们项目中有个 app.log 的日志文件,我们普通读取都使用 vi app. ...
- Linux下清空文件的常用方法
1. 本人用的最多,感觉也是最方便的: > filename.log 2. : > filename.log 3. cat /dev/null > filename.log
- 几种fullpage用法及demo
jQuery全屏滚动插件fullPage.js https://github.com/alvarotrigo/fullPage.js http://www.dowebok.com/77.html 全屏 ...
- HDU_1158_Employment Planning_dp
Employment Planning Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Othe ...
- UICollectionView(一)基本概念
整体预览 高等级的包含和管理(Top-level containment and management) UICollectionView UICollectionViewController UIC ...
- AcDbTable 类
Table 例子学习笔记在这个例子中,ARX向我们展示了ACDBTABLE类的一些基本操作方法,ACDBTABLE类是ACAD2005及其以后的产品,应该是说ACDBDATATABLE的升级产品,Ac ...