hdu 2899 Strange fuction (二分法)
Strange fuction
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2278 Accepted Submission(s): 1697
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.
100
200
-178.8534
//0MS 224K 590 B G++
/* 题意:
给出一关系式:
F(x) = 6 * x^7+8*x^6+7*x^3+5*x^2-y*x (0 <= x <=100)
和y的值,求x在范围(0,100)内时F(x)能取得的最小值 二分法:
很容易可以看出函数F(x)在(0,100)内是先减后增的,故用二分法求其倒数的零值点,然后用零值
再代入原式即可求出最值 */
#include<stdio.h>
#define e 1e-7
double fac(double a,double b)
{
return *a*a*a*a*a*a*a+*a*a*a*a*a*a+*a*a*a+*a*a-b*a;
}
double fac0(double a,double b)
{
return *a*a*a*a*a*a+*a*a*a*a*a+*a*a+*a-b;
}
int main(void)
{
int t;
double n;
scanf("%d",&t);
while(t--)
{
scanf("%lf",&n);
double l=;
double r=;
while(r-l>e){
double mid=(l+r)/;
if(fac0(mid,n)>) r=mid;
else l=mid;
}
printf("%.4lf\n",fac(r,n));
}
return ;
}
hdu 2899 Strange fuction (二分法)的更多相关文章
- hdu 2899 Strange fuction
http://acm.hdu.edu.cn/showproblem.php?pid=2899 Strange fuction Time Limit: 2000/1000 MS (Java/Others ...
- ACM : HDU 2899 Strange fuction 解题报告 -二分、三分
Strange fuction Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Tot ...
- hdu 2899 Strange fuction (二分)
题目链接:http://acm.hdu.edu.cn/showproblem.pihp?pid=2899 题目大意:找出满足F(x) = 6 * x^7+8*x^6+7*x^3+5*x^2-y*x ( ...
- hdu 2899 Strange fuction——模拟退火
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2899 还可三分.不过只写了模拟退火. #include<iostream> #include& ...
- hdu 2899 Strange fuction —— 模拟退火
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2899 模拟退火: 怎么也过不了,竟然是忘了写 lst = tmp ... 还是挺容易A的. 代码如下: # ...
- HDU 2899 Strange fuction 【三分】
三分可以用来求单峰函数的极值. 首先对一个函数要使用三分时,必须确保该函数在范围内是单峰的. 又因为凸函数必定是单峰的. 证明一个函数是凸函数的方法: 所以就变成证明该函数的一阶导数是否单调递增,或者 ...
- hdu 2899 Strange fuction 模拟退火
求 F(x) = 6 * x^7+8*x^6+7*x^3+5*x^2-y*x (0 <= x <=100)的最小值 模拟退火,每次根据温度随机下个状态,再根据温度转移 #include& ...
- HDU.2899.Strange fuction(牛顿迭代)
题目链接 \(Description\) 求函数\(F(x)=6\times x^7+8\times x^6+7\times x^3+5\times x^2-y\times x\)在\(x\in \l ...
- HDU 2899 Strange fuction [二分]
1.题意:给一个函数F(X)的表达式,求其最值,自变量定义域为0到100 2.分析:写出题面函数的导函数的表达式,二分求导函数的零点,对应的就是极值点 3.代码: # include <iost ...
随机推荐
- 最大公约数(gcd模板)
int gcd(int a,int b) { ) { int t=a%b; a=b; b=t; } return a; }
- MySQL为何不建议使用null列
Preface Null is a special constraint of columns.The columns in table will be added null cons ...
- NFS文件系统存储服务部署
1 NFS介绍 1.1 什么是NFS? NFS是Network File System的缩写,中文名称是网络文件系统.它的主要功能是通过网络让不用的主机系统之间可以共享文件或者目录.NFS客户端通过挂 ...
- HttpServletRequest cannot be resolved to a type The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path
HttpServletRequest cannot be resolved to a type The superclass "javax.servlet.http.HttpServlet& ...
- tcl之其他命令-eval/source
- Python常用函数记录
Python常用函数/方法记录 一. Python的random模块: 导入模块: import random 1. random()方法: 如上如可知该函数返回一个[0,1)(左闭右开)的一个随机的 ...
- 对Neural Machine Translation by Jointly Learning to Align and Translate论文的详解
读论文 Neural Machine Translation by Jointly Learning to Align and Translate 这个论文是在NLP中第一个使用attention机制 ...
- ZOJ3329 概率DP
One Person Game Time Limit: 1 Second Memory Limit: 32768 KB Special Judge There is a very ...
- [USACO12JAN]视频游戏的连击Video Game Combos(AC自动机+DP)
Description 贝西正在打格斗游戏.游戏里只有三个按键,分别是“A”.“B”和“C”.游戏中有 N 种连击 模式,第 i 种连击模式以字符串 Si 表示,只要贝西的按键中出现了这个字符串,就算 ...
- 使用perl发邮件
如果你使用的是 window 系统,没有 sendmail 工具.这时你就可以使用 perl 的 MIME:Lite 模块作为邮件客户端来发送邮件. 这里我们直接用 cpan 来安装(需要 root ...