andmej / acm

My solutions for problems from the UVa Online Judge (Valladolid).

This URL has Read+Write access

acm / 10195 - Knights of the round table / 10195.cpp
100644 22 lines (19 sloc) 0.419 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>
#include <math.h>
#include <cassert>
 
using namespace std;
 
main(){
  double a,b,c,s,r, temp;
  while (cin >> a >> b >> c){
    s = (a+b+c)/2;
    temp = s*(s-a)*(s-b)*(s-c);
    assert(temp >= 0);
    //cout << "s es : " << s << endl;
    if (s==0.0)
      r = 0.0;
    else
      r = sqrt(temp)/s;
    printf("The radius of the round table is: %0.3f\n", floor(r*1000+0.5)/1000);
  }
  return 0;
}