当前位置:网站首页>Uva5009 error curves three points
Uva5009 error curves three points
2022-06-26 13:11:00 【YJEthan】
The question : Find the minimum value of the maximum value of some concave functions with openings upward ( If you don't understand, read it carefully twice )
analysis : The minimum value of the maximum value of some concave functions with an upward opening is still a concave function
Finding the maximum value of the concave convex function obviously uses three points . See the code for details. , Similar to dichotomy , It's just two points in the middle , Function that doesn't understand , Draw more pictures and you can write them .
#include<stdio.h>
#include<math.h>
#include<algorithm>
using namespace std;
int n,a[10002],b[10002],c[10002];
double m1,m2,l,r,ans;
double solve(double x)
{
int i=0;
double cont=a[0]*x*x+b[0]*x+c[0];
for(i=1;i<n;i++)
cont=max(cont,a[i]*x*x+b[i]*x+c[i]);
return cont;
}
int main()
{
int t,i;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d%d%d",&a[i],&b[i],&c[i]);
}
l=0.0;r=1000.0;
for(i=0;i<100;i++)
{
m1=(l+r)/2.0;
m2=(m1+l)/2.0;
if(solve(m1)>solve(m2))
{
r=m1;
}
else l=m2;
}
ans=(l+r)/2.0;
printf("%.4lf\n",solve(ans));
}
return 0;
}边栏推荐
- QT .pri 的建立与使用
- Electron official docs series: Development
- H - Sumsets POJ 2229
- scrapy——爬取漫画自定义存储路径下载到本地
- 倍福PLC通过程序获取系统时间、本地时间、当前时区以及系统时间时区转换
- 黑马笔记---常用API
- Explain C language 10 in detail (C language series)
- 利用scrapy爬取句子迷网站优美句子存储到本地(喜欢摘抄的人有福了!)
- Go structure method
- Openlayers drawing dynamic migration lines and curves
猜你喜欢
随机推荐
Appearance mode (facade)
zoopeeper设置acl权限控制(只允许特定ip访问,加强安全)
Deep parsing MySQL binlog
Do you know the limitations of automated testing?
Guacamole installation
Learning Processing Zoog
Electron official docs series: Development
倍福将EtherCAT模块分到多个同步单元运行--Sync Units的使用
倍福PLC实现绝对值编码器原点断电保持---bias的使用
Explain C language 10 in detail (C language series)
体现技术深度(无法速成)
Dark horse notes - Common APIs
National standard gb28181 protocol easygbs video platform TCP active mode streaming exception repair
Electron official docs series: Get Started
Verilog中的系统任务(显示/打印类)--$display, $write,$strobe,$monitor
解中小企业之困,百度智能云打个样
QT .pri 的建立与使用
倍福NC轴状态转移图解析
KVM video card transparent transmission -- the road of building a dream
Copy multiple Excel files and name them different
![[BSidesCF 2019]Kookie 1](/img/22/585d081668e67b8389a1b90aaebe9d.png)





