hdu Strange fuction
本题是一道二分题,但是要利用导数来求最小值。对原函数进行求导,得到的导函数为f(x)=42*pow(x,6)+48*pow(x,5)+21*pow(x,2)+10*x-y;因为0<=x<=100,所以当
y>46802200时,f(x)恒小于0,故F(x)单调递减。当y<46802200时,可知原函数先递减后递增,因此可利用二分找到导函数为零的x的值,再将此x带入原函数就可以得到最小值。
#include"iostream"
#include"stdio.h"
#include"algorithm"
#include"string.h"
#include"cmath"
#define mi 1e-8
using namespace std;
double cf(double x,double y)
{
return *pow(x,)+*pow(x,)+*pow(x,)+*x*x-y*x;
}
double cff(double x)
{
return *pow(x,)+*pow(x,)+*pow(x,)+*x;
}
int main()
{
int t;
cin>>t;
while(t--){
double y;
cin>>y;
if(y>=)
{double t=cf(100.0,y);printf("%.4lf\n",t);}
else
{
double a=0.0;
double b=100.0;
while(b-a>mi)
{
double m=(b+a)/2.0;
if(cff(m)<y) a=m;
else b=m;
}
printf("%.4lf\n",cf(a,y));
}
}
return ;
}
hdu 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 (二分法)
Strange fuction Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)T ...
- Strange fuction hdu 2899
Strange fuction Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)T ...
- 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
Strange fuction Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Tot ...
- HDU2899 Strange fuction 【二分】
Strange fuction Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- (二分搜索 )Strange fuction -- HDU -- 2899
链接: http://acm.hdu.edu.cn/showproblem.php?pid=2899 Time Limit: 2000/1000 MS (Java/Others) Memory ...
随机推荐
- html css js
html 回顾 字体:font 属性: color: 颜色 size: 字号 表格:table 标签: tr:表格中的行 td: 单元行中的单元格 th:通常使用在table中的第一行, 成为表头, ...
- Java for LeetCode 140 Word Break II
Given a string s and a dictionary of words dict, add spaces in s to construct a sentence where each ...
- 5.前端笔记之jquery部分
一.简介 jQuery是一个兼容多浏览器的javascript库,核心理念是write less,do more(写得更少,做得更多).jQuery在2006年1月由美国人John Resig在纽约的 ...
- hdu 1098 Lowest Bit 解题报告
题目链接:http://code.hdu.edu.cn/game/entry/problem/show.php?chapterid=1§ionid=2&problemid=22 ...
- linux下重启tomcat、实时查看tomcat运行日志
在Linux系统下,重启Tomcat使用命令操作的! 首先,进入Tomcat下的bin目录 cd /usr/local/tomcat/bin 使用Tomcat关闭命令 ./shutdown.sh 查看 ...
- 配置SecureCRT连接本地虚拟机中的Linux系统
转自:http://www.pythoner.com/196.html 由于平时公司开发时都是使用SecureCRT连接的Linux服务器,所以也想使用SecureCRT在自己电脑上连接本地虚拟机中的 ...
- ScrollView与TableView实现选择效果
在cocos2dx中,ScrollView与TableView都可以实现选择效果,其中ScrollView较为原始,TableView的格子大小可以不与winSize一样大. ScrollView实现 ...
- mysql 建表语句
修改id为自动增长: alter table book b_ISBN int(11) auto_increment; 自动增长要加的:auto_increment 基本的sql语句: 选择:sel ...
- adb logcat 命令
转自:http://blog.csdn.net/tumuzhuanjia/article/details/39555445 1. 解析 adb logcat 的帮助信息 在命令行中输入 adb log ...
- C++查询网站
1.C++外文api查询 http://www.cplusplus.com/ 2.https://isocpp.org/ 3.Juce学习 http://www.thinksaas.cn/favori ...