FInd the Max area.
1. Three-point method
2. NAN (not comparable with number)
http://acm.timus.ru/problem.aspx?space=1&num=1874
#include <iostream>#include<algorithm>#include<cstdio>#include<cmath>using namespacestd;#defineEPS 1e-9//1874 to calculate the max area//divide quardnage into and areas//helper function to Cal the areaDoubleCal_area (DoubleADoubleBDoublec) { //Check if theree exists triangle, otherwise, it'll rturn nan, which is not comparable if(c + a <= B | | C + b <=a | | a+b <=c)return-1; Doubles = (a+b+c)/2.0; DoubleS1 = c*c/4; DoubleS2 = sqrt (s* (s-a) * (s-b) * (S-c)); returns1+S2;}intMain () {//freopen ("Input.txt", "R", stdin); DoubleA =0, B =0; CIN>> A; CIN >>b; Doublec =0; //uble S1 = 0, s2 = 0; DoubleMax =0; //The range of C is [0 A+b] DoubleL =0, r = A +b; Doublem,mm; Doublemv, MMV; while(L + EPS <r) {m= (r-l)/2+l; MM= (r-m)/2+m; MV=Cal_area (a,b,m); //printf ("%f\n", MV);MMV =Cal_area (A, B, mm); //Find first construct area if(MV <= MMV) L = m;//Edge Case if mv = = MMV (move to bigger one tot get bigger c) ElseR =mm; } printf ("%.7f\n", MV, MMV, mv > MMV?MV:MMV); return 0;}
1874 football game (three-way and method to compute, the area of Trianngle)