当前位置:网站首页>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;
}边栏推荐
- tauri vs electron
- 倍福PLC通过程序获取系统时间、本地时间、当前时区以及系统时间时区转换
- First pass! Baidu AI Cloud Xiling platform has obtained the authoritative certification of digital human ability evaluation from the Institute of information technology
- Deeply analyze the differences between dangbei box B3, Tencent Aurora 5S and Xiaomi box 4S
- 软件测试报告应该包含的内容?面试必问
- 倍福PLC通过MC_ReadParameter读取NC轴的配置参数
- sql 将数据表b字段值赋值到数据表a中某一列
- mariadb学习笔记
- System tasks (display / print class) in Verilog - $display, $write, $strobe, $monitor
- [BSidesCF 2019]Kookie 1
猜你喜欢

装饰器(Decorator)

首批通过!百度智能云曦灵平台获信通院数字人能力评测权威认证

P5733 【深基6.例1】自动修正

Use the script to crawl the beautiful sentences of the sentence fan website and store them locally (blessed are those who like to excerpt!)

Bridge mode

自动化测试的局限性你知道吗?

What are the common categories of software testing?

倍福TwinCAT3 NCI在NC轴界面中的基本配置和测试

MariaDB study notes

详细讲解C语言11(C语言系列)
随机推荐
Processsing mouse interactive learning
倍福Ethercat模块网络诊断和硬件排查的基本方法
mariadb学习笔记
10秒内完成火灾预警,百度智能云助力昆明官渡打造智慧城市新标杆
F - Charm Bracelet
Uva10341 solve it
装饰器(Decorator)
利用scrapy爬取句子迷网站优美句子存储到本地(喜欢摘抄的人有福了!)
倍福PLC实现绝对值编码器原点断电保持---bias的使用
processing 函数translate(mouseX, mouseY)学习
Accumulation of interview questions
C语言:练习题二
J - Wooden Sticks poj 1065
. Net Maui performance improvement
Goto statement to realize shutdown applet
OPLG: 新一代云原生可观测最佳实践
Power Designer - Custom Comment button
Coprime and non coprime of template problems of Chinese remainder theorem
首批通过!百度智能云曦灵平台获信通院数字人能力评测权威认证
Script - crawl the customized storage path of the cartoon and download it to the local