博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
三分法
阅读量:4518 次
发布时间:2019-06-08

本文共 1001 字,大约阅读时间需要 3 分钟。

HDU

#include 
#include
#include
#include
#include
using namespace std;typedef long long ll;const int N = 1e4+5;inline int read() { char c=getchar(); int x=0,f=1; while(c<'0' || c>'9') {if(c=='-')f=-1; c=getchar();} while(c>='0' && c<='9') {x=x*10+c-'0'; c=getchar();} return x*f;}int n, a[N], b[N], c[N];double f(double x) { double x2 = x*x, ans = a[1]*x2 + b[1]*x + c[1]; for(int i=2; i<=n; i++) ans = max(ans, a[i]*x2 + b[i]*x + c[i]); return ans;}void solve() { double l=0, r=1000; for(int i=0; i<100; i++) { double len = (r-l)/3, m1 = l+len, m2 = r-len; if(f(m1) < f(m2)) r = m2; else l = m1; } printf("%.4lf\n", f(l));}int main() { freopen("in", "r", stdin); int T = read(); while(T--) { n = read(); for(int i=1; i<=n; i++) a[i] = read(), b[i] = read(), c[i] = read(); solve(); }}

转载于:https://www.cnblogs.com/candy99/p/6764766.html

你可能感兴趣的文章
SalesForce自定义按钮(javascript执行),点击按钮更新Filed
查看>>
Android中ViewPager实现滑动条及与Fragment结合的实例教程
查看>>
组织过程资产与事业环境因素
查看>>
学习和思考的要点
查看>>
16年收官之战,堪称完美,祝愿大家2017一举成名天下闻,虎啸龙吟展宏图
查看>>
使用jquery获取ul的li的值赋值
查看>>
Struts 2 标签
查看>>
关于 BFC 的一些实践例子
查看>>
201671010129 2016—2017—2 《Java程序设计》学习Java总结
查看>>
[每日一讲] Python系列:变量、内存管理与传递
查看>>
UI设计黄金法则
查看>>
HTML页面的重绘(repaint)和重流(reflow)
查看>>
将联系人导入到iPhone模拟器
查看>>
Android常用URI以及URI简介
查看>>
Postgresql 远程连接配置
查看>>
奇偶个数
查看>>
解决请求筛选模块被配置为拒绝包含的查询字符串过长的请求
查看>>
PHP基础
查看>>
Oracle 的ORION工具简单使用
查看>>
局域网永恒之蓝病毒发包的解决方案之二
查看>>