Friday, March 18, 2016

UVa 10195 - The Knights Around The Round Table

#include <bits/stdc++.h>
#define LL  long long
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define pri(a) cout<<a<<endl
#define prii(a,b) cout<<a<<" "<<b<<endl
#define hi printf("Hello World\n")
#define PI 2*acos(0.0)
#define pcs printf("CASE# %d:\n", ++cs);
#define WRITE(fn) freopen(fn, "w", stdout);
using namespace std;

/// Radius of inscribed circle = Triangle Area / Half Perimeter
/// s = (a+b+c)/2+1e-8; -> add eps for case 0,0,0

int main()
{
    double a,b,c,s,area,r;

    while(cin>>a>>b>>c)
    {
        s = (a+b+c)/2+1e-8;  ///** add eps
        area = sqrt(s*(s-a)*(s-b)*(s-c));
        r = area/s;
        printf("The radius of the round table is: %.3lf\n", r);
    }
    return 0;
}

No comments:

Post a Comment