三分_1
来源:互联网 发布:unity3d 积木游戏 编辑:程序博客网 时间:2024/05/16 18:58
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.
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
2100200
Sample Output
-74.4291-178.8534
三分题。。二分应用单调函数,而三分应用于单峰函数,此函数恰是一个单峰函数。这题可以直接用三分,当然也求导求极值,从而转化为二分题
#include<iostream>#include"math.h"#include"cstdio"typedef long long LL;const double EPS=1e-7;LL y;using namespace std;//F(x) = 6 * x^7+8*x^6+7*x^3+5*x^2-y*x (0 <= x <=100)double f(double x){ return 6*x*x*x*x*x*x*x+8*x*x*x*x*x*x+7*x*x*x+5*x*x-y*x;}int main(){ int T; cin>>T; while(T--) { cin>>y; double low=0.0,high=100.0; double mid,mmid; while(high-low>EPS) { mid=(high-low)/2+low; mmid=(high-mid)/2+mid; if(f(mid)<f(mmid)) high=mmid; else low=mid; } printf("%.4lf\n",f(mid)); } return 0;}
0 0
- 三分_1
- 三分
- 三分
- 三分
- 三分
- 三分
- 三分
- 三分
- 三分
- 三分
- 三分
- 三分
- 三分
- 三分
- 三分
- 三分
- bzoj1857 三分套三分
- 【BZOJ1857】三分套三分
- kvm qemu内幕介绍
- Antenna Placement--匈牙利算法
- Lucene教程(一) 创建索引
- Java连接MySQL数据库并且执行建表和插入数据
- 设计模式:职责链模式
- 三分_1
- arcgis javascript api中关闭infowindow或者Popup 右上角的 关闭(close)和最大化(Maximize) 按钮
- C# static、 const和readonly区别
- 22. Generate Parentheses QuestionEditorial Solution
- [action] deep learning 深度学习 tensorflow 实战(2) 实现简单神经网络以及随机梯度下降算法S.G.D
- Handle的一些用法
- Android 如何通知用户更新app的版本
- Ubuntu下的文件比较工具--meld
- jquery操作属性