显示代码纯文本
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int T,A,B,C,N;
int a[10010],b[10010],c[10010];
double MAX(double a,double b)
{
if(a>b)return a;
else return b;
}
double MIN(double a,double b)
{
if(a<b)return a;
else return b;
}
double get(double x,int i)
{
return (a[i]*x*x+b[i]*x+c[i]);
}
double Get(double x)
{
double ha=-1e50;
for(int i=1;i<=N;i++)
{
ha=MAX(ha,get(x,i));
}
return ha;
}
double CALC()
{
double l=0.0,r=1000.0;
double ans1=0,ans2=0;
while(r-l>=1e-9)
{
double mid=(l+r)/2.0,mm=(mid+r)/2.0;
ans1=Get(mid),ans2=Get(mm);
if(ans1<ans2)r=mm;
else l=mid;
}
return Get(l);
}
int main()
{
freopen("errorcurves.in","r",stdin);
freopen("errorcurves.out","w",stdout);
scanf("%d",&T);
while(T--)
{
scanf("%d",&N);
for(int i=1;i<=N;i++)
{
scanf("%d%d%d",&a[i],&b[i],&c[i]);
}
printf("%.2lf\n",CALC());
}
fclose(stdin);
fclose(stdout);
return 0;
}