HDU 2899 Strange fuction
来源:互联网 发布:deepin 知乎 编辑:程序博客网 时间:2024/05/22 16:53
题目地址: http://acm.hdu.edu.cn/showproblem.php?pid=2899
分析:要求最小值,求导,因为x范围为0~100,所以导函数单调递增,可知原函数是一个先递减后递增的函数,所以导函数为0的x值即为原函数的最小值。
二分求解。
源代码:
#include <iostream>#include <cstdio>#include <cstdlib>#include <cmath>#include <cstring>#include <string>#include <algorithm>#include <vector>#include <set>#include <map>#include <queue>using namespace std;/*freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);*/double y;double test(double x){ return 42*pow(x,6)+48*pow(x,5)+21*x*x+10*x-y;}int main(){ int t,i; cin>>t; while(t--) { scanf("%lf",&y); double r=100.0,l=0.0,mid; while((r-l)>1e-6) { mid=(r+l)/2; if(test(mid)>0) r=mid; else l=mid; } printf("%.4f\n",6*pow(mid,7)+8*pow(mid,6)+7*mid*mid*mid+5*mid*mid-y*mid); } return 520;}
- HDU 2899 Strange fuction
- hdu 2899 Strange fuction
- hdu 2899 Strange fuction
- HDU 2899 Strange fuction
- hdu 2899 Strange fuction
- HDU 2899-Strange fuction
- hdu 2899 Strange fuction
- hdu--2899--Strange fuction
- hdu 2899 Strange fuction
- HDU 2899 Strange fuction
- HDU 2899 Strange fuction
- hdu 2899 Strange fuction
- hdu 2899 Strange fuction
- HDU 2899 Strange fuction
- HDU 2899 Strange fuction
- hdu 2899 Strange fuction
- Strange fuction ----HDU 2899
- hdu 2899 Strange fuction
- 1009 最短路
- mysql性能及内存优化
- 2012 腾讯校招Web前端笔试的一道题,很值得怀念。。。
- MFC的CFileDialog和几个类之间的关系
- 玩转php变量
- HDU 2899 Strange fuction
- PHP 静态变量 变量函数 递归函数
- 1010_1020 最短路
- onmouse 在div包含子元素 失效问题
- 联想双显卡用户Win8下独显被禁止解决方案
- android 面试提纲
- 为什么需要实体类
- centos6.2 双系统安装
- 1018 最短路