ACM : HDU 2899 Strange fuction 解题报告 -二分、三分
Strange fuction Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 5933 Accepted Submission(s): 4194 Problem Description
Now, here is a 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. Input
The first line of the input contains an integer T(1<=T<=100) which means the number of test cases. Then T lines follow, each line has only one real numbers Y.(0 < Y <1e10) Output
Just the minimum value (accurate up to 4 decimal places),when x is between 0 and 100. Sample Input
2
100
200 Sample Output
-74.4291
-178.8534 Author
Redow Recommend
lcy //三分二分都可以,导数单调,求导后二分值 AC代码
#include"iostream"
#include"algorithm"
#include"cstdio"
#include"cstring"
#include"cmath"
#define max(a,b) a>b?a:b
#define min(a,b) a<b?a:b
#define MX 10000 + 50
using namespace std;
double y; double f(double x) { //求导
return *pow(x,)+*pow(x,)+*x*x+*x-y; // F(x) = 6 * x^7+8*x^6+7*x^3+5*x^2-y*x (0 <= x <=100)
} double F(double x) {
return * pow(x,)+*pow(x,)+*x*x*x+*x*x-y*x;// F(x) = 6 * x^7+8*x^6+7*x^3+5*x^2-y*x (0 <= x <=100)
} int main() {
int T;
while(cin>>T) {
for(int qq=; qq<T; qq++) {
cin>>y;
if(f()>) {
printf("%.4f\n",F());
} else if(f()<) {
printf("%.4f\n",F());
} else {
double l=; // 0 l r 100
double r=; // -------------------------
double mid;
while(r-l>1e-) {
mid=(r+l)/2.0;
if(f(mid)>) {
r=mid;
} else {
l=mid;
}
}
printf("%.4f\n",F(mid));
}
}
}
return ;
}
ACM : 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 ...
- 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 (二分法)
Strange fuction Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)T ...
- HDU 2899 Strange fuction [二分]
1.题意:给一个函数F(X)的表达式,求其最值,自变量定义域为0到100 2.分析:写出题面函数的导函数的表达式,二分求导函数的零点,对应的就是极值点 3.代码: # include <iost ...
- 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 ...
- ACM: HDU 1028 Working out 解题报告-DP
Working out time limit per test 2 seconds memory limit per test 256 megabytes input standard inpu ...
- HDU 2899 Strange fuction 【三分】
三分可以用来求单峰函数的极值. 首先对一个函数要使用三分时,必须确保该函数在范围内是单峰的. 又因为凸函数必定是单峰的. 证明一个函数是凸函数的方法: 所以就变成证明该函数的一阶导数是否单调递增,或者 ...
随机推荐
- Bootstrap 排版 笔记
Bootstrap 使用 Helvetica Neue. Helvetica. Arial 和 sans-serif 作为其默认的字体栈. 使用 Bootstrap 的排版特性,您可以创建标题.段落. ...
- SQL脚本书写的几点建议
1.索引很关键,创建合理的索引,提升查询速度: DBCC FREEPORCCACHE DBCC DROPCLEANBUFFERS ...
- GoLang搞一个基本的HTTP服务
慢慢和python的对应一下看看. package main import ( "fmt" "net/http" "strings" &qu ...
- android 入门-基础了解
strings.xml – 文字資源. colors.xml – 顏色資源. dimens.xml – 尺寸資源. arrays.xml – 陣列資源. styles.xml – 樣式資源. #RGB ...
- 老生常谈,正确使用memset
转自:http://blog.csdn.net/my_business/article/details/40537653 前段项目中发现一个问题,程序总是在某个dynamic_cast进行动态转换时出 ...
- ok6410按键中断编程,linux按键裸机
6410按键中断编程 一.流程分析 外部中断控制寄存器(s3c6410x 359页) 1.EINTxCONy: 外部中断组x的第y个控制器.这个就是设置中断的触发方式.有5种触发方式. 2.EINT ...
- [Liferay6.2]Connect to ajax.googleapis.com …… timed out
启动liferay 6.2 tomcat之后,后台会报一大段的异常信息,主要异常信息如下: -- :: org.apache.shindig.gadgets.http.BasicHttpFetcher ...
- Codeforces Round #248 (Div. 2) C. Ryouko's Memory Note
题目链接:http://codeforces.com/contest/433/problem/C 思路:可以想到,要把某一个数字变成他的相邻中的数字的其中一个,这样总和才会减少,于是我们可以把每个数的 ...
- spfa求最长路
http://poj.org/problem?id=1932 spfa求最长路,判断dist[n] > 0,需要注意的是有正环存在,如果有环存在,那么就要判断这个环上的某一点是否能够到达n点,如 ...
- Windows7系统主题制作全程教程
jpg 改 rar