当前位置:网站首页>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;
}边栏推荐
- UVa11582 [快速幂]Colossal Fibonacci Numbers!
- postgis 地理化函数
- National standard gb28181 protocol easygbs video platform TCP active mode streaming exception repair
- 单例的常用创建和使用方式
- 享元模式(Flyweight)
- 倍福PLC旋切基本原理和应用例程
- UVA5009 Error Curves三分
- 适配器模式(Adapter)
- What should the software test report include? Interview must ask
- Electron official docs series: Distribution
猜你喜欢

Processing random generation line animation

National standard gb28181 protocol easygbs cascaded universal vision platform, how to deal with live message 403?

The El form item contains two inputs. Verify the two inputs

组合模式(Composite )

Machine learning notes - seasonality of time series

Mode pont

What are the common categories of software testing?

2、并行接口、协议和相关芯片介绍(8080、8060)

倍福Ethercat模块网络诊断和硬件排查的基本方法

Group counting practice experiment 9 -- using cmstudio to design microprogram instructions based on segment model machine (2)
随机推荐
IDC report: the AI cloud market share of Baidu AI Cloud ranks first for six consecutive times
sql 将数据表b字段值赋值到数据表a中某一列
原型模式(prototype)
Deep parsing MySQL binlog
Dark horse notes - Common APIs
倍福CX5130换卡对已有的授权文件转移操作
This function has none of deterministic, no SQL solution
Basic principle and application routine of Beifu PLC rotary cutting
National standard gb28181 protocol easygbs cascaded universal vision platform, how to deal with live message 403?
UVA5009 Error Curves三分
Fire warning is completed within 10 seconds, and Baidu AI Cloud helps Kunming Guandu build a new benchmark of smart city
Appearance mode (facade)
Digital signal processing -- Design of linear phase type (Ⅰ, Ⅲ) FIR filter (1)
倍福将EtherCAT模块分到多个同步单元运行--Sync Units的使用
postgis计算角度
[BSidesCF 2019]Kookie 1
Vivado error code [drc pdcn-2721] resolution
KVM video card transparent transmission -- the road of building a dream
Electron official docs series: Get Started
P2393 yyy loves Maths II