Wednesday, December 20, 2017

10347 - Medians Uva Solution Logic

//

Very Easy Problem -----

When Three Medians( মধ্যমা ) Are Given , Then Using Heron's Formula , We can solve the area
/////

Now See Code ,


#include<bits/stdc++.h>

// Nayeem Shahriar Joy , Applied Physics & Electronic Engineering , University of Rajshahi.

using namespace std;


int main()
{
   double u,v,w,s,area;

    while (scanf("%lf%lf%lf", &u, &v, &w) == 3){

         s = (u + v + w) / 2.0;
         area = (4.0 / 3.0) * sqrt(s * (s - u) * (s - v) * (s - w));

        if(area > 0)
            printf("%0.3lf\n", area);
        else
            printf("-1.000\n");

    }
    return 0;
}

No comments:

Post a Comment