... HAVE U TRIED .... AT LEAST 3 TIMES ... OK U CAN SEE THIS ...

Tuesday, December 31, 2013

LOJ-1331 :: Agent J

#include <iostream>
#include <math.h>
#include <cstdio>
using namespace std ;
int main ()
{
     double r1,r2,r3 ,a,b,c ,A,B,C ,p ,s ,s1,a1,a2,a3 ,rs  ;
    int i , t , it ;
    cin>>t ;

    for (it=1 ; it<=t ; it++)
    {
        cin>>r1>>r2>>r3 ;
        a=r1 + r2 ;
        b=r2+ r3 ;
        c=r3 + r1 ;

        A=acos((b*b+c*c-a*a)/(2.0*b*c)) ;
        B=acos((a*a+c*c-b*b)/(2.0*a*c)) ;
        C=acos((a*a+b*b-c*c)/(2.0*a*b)) ;

        a1=(0.5)*r1*r1*B ;
        a2=(0.5)*r2*r2*C ;
        a3=(0.5)*r3*r3*A ;
        s1=a1+a2+a3 ;

        s=(a+b+c)/2.0 ;
        p=sqrt(s*(s-a)*(s-b)*(s-c)) ;

        rs=p-s1 ;
     printf ("Case %d: %0.10lf\n",it,rs) ;

    }

    return 0 ;
}