Topic Portal
1 /*2 Three points: concave (convex) function to find the Extremum3 */4#include <cstdio>5#include <algorithm>6#include <cstring>7#include <cmath>8 using namespacestd;9 Ten Const intMAXN = 1e4 +Ten; One Const intINF =0x3f3f3f3f; A Const DoubleEPS =0.0000000001; - structF { - DoubleA, B, C; the }F[MAXN]; - intN; - - DoubleCalDoublex) { + Doubleres =-INF; - for(intI=1; i<=n; ++i) { +res = max (res, F[I].A * x * x + f[i].b * x +f[i].c); A } at returnRes; - } - - intMainvoid) {//hdoj 3714 Error Curves - //freopen ("hdoj_3714.in", "R", stdin); - in intT scanf ("%d", &T); - while(t--) { toscanf ("%d", &n); + for(intI=1; i<=n; ++i) { -scanf ("%LF%LF%LF", &F[I].A, &f[i].b, &f[i].c); the } * $ DoubleL =0.0, r =1000.0;Panax Notoginseng for(intI=1; i<= -; ++i) { - DoubleMid = (L + r)/2; the DoubleRmid = (mid + R)/2; + if(Cal (Mid) < cal (Rmid)) R =Rmid; A ElseL =mid; the } +printf ("%.4f\n", Cal (R)); - } $ $ return 0; -}
Three points hdoj 3714 Error Curves