HDU 3714 Error Curves (three points)

Source: Internet
Author: User

Error Curves

Time limit:4000/2000 MS (java/others) Memory limit:65536/65536 K (java/others)
Total submission (s): 1198 Accepted Submission (s): 460


Problem Descriptionjosephina is a clever girl and addicted to machine learning recently. She
Pays much attention to a method called Linear discriminant analysis, which
has many interesting properties.
In order to test the algorithm ' s efficiency, she collects many datasets.
What's more, each data was divided into the parts:training data and test
Data. She gets the parameters of the model on training data and test the
Model on test data. To hers surprise, she finds each dataset ' s test error curve is just a parabolic curve. A parabolic curve corresponds to a quadratic function. In mathematics, a quadratic function is a polynomial function of the form f (x) = ax2 + bx + C. The quadratic would degrade to linear function if a = 0.



It's very easy to calculate the minimal error if there are only one Test error curve. However, there is several datasets, which means Josephina would obtain many parabolic curves. Josephina wants to get the tuned parameters, the best performance on all datasets. So she should take the all error curves into account, i.e., she had to deal with many quadric functions and make a new error D Efinition to represent the total error. Now, she focuses on the following new function ' s minimum which related to multiple quadric functions. The new function F (x) is defined as follows:f (x) = Max (Si (x)), i = 1...N. The domain of x is [0, 1000]. Si (x) is a quadric function. Josephina wonders the minimum of F (x). Unfortunately, it ' s too hard for her and solve this problem. As a super programmer, can help her? 


Inputthe input contains multiple test cases. The first line is the number of cases T (T < 100). Each case is begins with a number n (n≤10000). Following n lines, each line contains three integers a (0≤a≤100), B (|b|≤5000), C (|c|≤5000), which mean the Corre Sponding coefficients of a quadratic function.


Outputfor each test case, output the answer in a line. Round to 4 digits after the decimal point.


Sample Input212 0 022 0 02-4 2


Sample Output0.00000.5000


Authorlin, Yue


Source2010 Asia Chengdu Regional Contest


Recommendzhouzeyong the problem desires a number of two functions when X is 0-1000 of the value of the function of the maximum value, all the maximum value of the output of the smallest one can be solved: three points, the intermediate update interval when the position can be changed, because the ontology is the minimum value Ps:esp take 1e-8 of the time, for WA, when opened to 1e-9 when the past, the reason may be the answer required to output 4 decimal points, and in the calculation of two functions when the calculation of x*x will generate 8 decimal places, all reserved 9 decimal places to ensure the accuracy of the loss
#include <stdio.h>#include<string.h>#include<iostream>#include<algorithm>using namespacestd;intN;structnode{DoubleA,b,c;} que[10005];Doubleesp=1e-9;DoublehFFDoublex) {     Doubletmax=que[0].a*x*x+que[0].b*x+que[0].c;  for(intI=1; i<n;i++) {Tmax=max (tmax,que[i].a*x*x+que[i].b*x+que[i].c); }   returnTmax;}voidcalculate () {DoubleL=0, r=1000.0; DoubleAns1,ans2;  while(l+esp<R) {       DoubleMid= (L+R)/2.0; DoubleMidmid= (MID+R)/2.0; Ans1=FF (mid); Ans2=FF (MIDMID); if(ans1<ans2) {R=Midmid; }       ElseL=mid; } printf ("%.4lf\n", ans1);}intMain () {intT; scanf ("%d",&t);  while(t--) {memset (que,0,sizeof(que)); scanf ("%d",&N);  for(intI=0; i<n;i++) {scanf ("%LF%LF%LF",&que[i].a,&que[i].b,&que[i].c);    } calculate (); }    return 0;}

HDU 3714 Error Curves (three points)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.