HDU3714 Error Curves(2010 Asia Chengdu Regional Contest)
題目連結:http://acm.hdu.edu.cn/showproblem.php?pid=3714
題意:給定開口向上的二次函式n個f[i] (0<i<n) 定義F(x)=max(si(x)); si(x)表示對於f[i] 當未知數取值x的時候對應的函式值
求F(x) (1<=x<=1000)的最小值
因為f(x)是一個下凸函式所以F(x)也是一個下凸函式,用三分來求最優解,此題精度卡的比較死。
程式碼如下:
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
const int maxn = 10010;
const double eps= 1e-9;
int a[maxn],b[maxn],c[maxn],n;
double calu(double x){
double ans = a[0]*x*x+b[0]*x+c[0];
for(int i=1;i<n;i++){
double t=a[i]*x*x+b[i]*x+c[i];
if(t>ans) ans=t;
}
return ans;
}
double there_search()
{
double l=0.0,r=1000.0;
double ll,rr;
while(l+eps<r){
ll=(2*l+r)/3;
rr=(2*r+l)/3;
if(calu(ll)>calu(rr))
l=ll;
else
r=rr;
}
return l;
}
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]);
double ans=there_search();
printf("%.4lf\n",calu(ans));
}
return 0;
}
相關文章
- The 2021 ICPC Asia Shenyang Regional Contest
- The 2024 ICPC Asia Nanjing Regional ContestNaN
- The 2022 ICPC Asia Nanjing Regional ContestNaN
- The 2023 ICPC Asia Macau Regional ContestMac
- The 2022 ICPC Asia Xian Regional Contest
- The 2022 ICPC Asia Hangzhou Regional Programming Contest
- HDU4091(2011 Asia Shanghai Regional Contest)AI
- The 2022 ICPC Asia Xian Regional Contest 前六題
- 2016-2017 ACM-ICPC Asia-Bangkok Regional ContestACM
- 2018-2019 ACM-ICPC, Asia Seoul Regional Contest——A - CircuitsACMUI
- The 2022 ICPC Asia Nanjing Regional Contest IGDA,和令人疑惑的MNaN
- The 2023 ICPC Asia Hangzhou Regional Contest (The 2nd Universal Cup. Stage 22: Hangzhou)
- Error Curves——錯誤曲線Error
- Chayas - 2023-2024 ICPC, Asia Yokohama Regional Contest 2023, Problem E
- The 2023 ICPC Asia Jinan Regional Contest (The 2nd Universal Cup. Stage 17: Jinan)補題記錄NaN
- 2017 ACM/ICPC Asia Regional Shenyang Online - 做題記錄ACM
- 2013 ACM/ICPC Asia Regional Online —— Warmup2 兩個水題ACM
- HDU4998 Rotate (2014 ACM/ICPC Asia Regional Anshan Online)ACM
- The 2023 ICPC Asia EC Regionals Online Contest (I)
- The 2024 ICPC Asia East Continent Online Contest (I)AST
- 2015 ACM/ICPC Asia Regional Shenyang Online-1012 Largest PointACM
- 2017-2018 ACM-ICPC Southeast Regional Contest (Div. 1)ACMAST
- 2017-2018 ACM-ICPC Pacific Northwest Regional Contest (Div. 1)ACM
- 2017-2018 ACM-ICPC, Central Europe Regional Contest (CERC 17)ACM
- HDU5023A Corrupt Mayor's Performance Art (2014 ACM/ICPC Asia Regional Guangzhou Online)ORMACM
- The 2024 ICPC Asia EC Regionals Online Contest (II) - Problem B. Mountain BookingAI
- The 2024 ICPC Asia EC Regionals Online Contest (II) - Problem H. Points Selection
- The 3rd Universal Cup. Stage 15: Chengdu
- Flutter 動畫曲線Curves 效果一覽Flutter動畫
- 2017-2018 ACM-ICPC Southwestern European Regional Programming Contest (SWERC 2017)ACM
- 2016-2017 ACM-ICPC Northwestern European Regional Programming Contest (NWERC 2016)ACM
- 2016-2017 ACM-ICPC Southwestern European Regional Programming Contest (SWERC 2016)ACM
- HDU 5052 Yaoge’s maximum profit 光禿禿的樹鏈拆分 2014 ACM/ICPC Asia Regional Shanghai Online...ACMAI
- 2019-2020 ICPC Southeastern European Regional Programming Contest (SEERC 2019) 補題記錄AST
- 2020-2021 ICPC NERC (NEERC), North-Western Russia Regional Contest (Northern Subregionals) E(離散化+尤拉回路)
- Revit二次開發-曲線三連:對curves進行排序排序
- Weekly Contest 387
- CF 2010 C2. Message Transmission Error (hard version) (*1700) 字串+雜湊Error字串