LA 5009
来源:互联网 发布:tensorflow spyder 编辑:程序博客网 时间:2024/06/05 19:50
题目:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=3010
思路:思路:由于f(x) = max{Si(x)},所有的S(x)都是下凸形函数,所以最后有意义的图形也是一个下凸形函数,所以直接进行三分求最小值就行了
二分法??
/**/#include<bits/stdc++.h> using namespace std;const int N = 1e4+5;int n,a[N],b[N],c[N];double f(double x){ double maxn = a[0]*x*x+b[0]*x+c[0]; for(int i = 1;i < n;i++) maxn = max(maxn,a[i]*x*x+b[i]*x+c[i]); return maxn;}int main(){ int T; scanf("%d",&T); while(T--) { scanf("%d",&n); for(int i = 0;i < n;i++) scanf("%d%d%d",&a[i],&b[i],&c[i]); int cnt = 0; double l = 0,r = 1000,m1,m2; while(cnt++ < 100) { m1 = l+(r-l)/3; m2 = r-(r-l)/3; if(f(m1) < f(m2)) r = m2; else l = m1; } printf("%.4f\n",f(m1)); } return 0;}
阅读全文
0 0
- LA 5009
- LA 5009 三分
- la la la, la la la
- la 5009 - Error Curves(三分)
- LA 5009 (HDU 3714) Error Curves 翻译
- 三分法(误差曲线,LA 5009)
- LA 5009 (HDU 3714) Error Curves (三分)
- #三分法判断单峰函数最值#附加例题LA 5009
- LA 3942
- LA 4670
- LA 3135
- LA 3644
- LA 3027
- LA 5059
- LA 3644
- La 3942
- LA 3126
- LA 4329
- 【python 爬虫】python中url链接编码处理方法
- [js高手之路]使用原型对象(prototype)需要注意的地方
- 支持向量机
- mac生成core文件和生成位置
- 最小树形图
- LA 5009
- cmd 高级用法
- app UI自动化框架改进----使用pa设计模式抽离页面元素
- java编程:无序整数序列,求连续子串最大和问题
- 稀疏编码系列1:Spatial Pyramid Matching 小结
- html版键盘
- 你应该知道的 RPC 原理
- 高可用架构设计之数据存储层
- upper_bound()和lower_bound()的使用