2012-04-28 15:04:04Morris

[UVA][Math] 11152 - Colourful Flowers

Problem E: Colourful Flowers

Time limit: 10 seconds


"Roses are red, violets are blue..."

Millionaire Mr Smith is well-known -- not for his wealth, but for his odd sense of "art"... Mr Smith has got a circular garden. On the boundary he picks three points and gets a triangle. He then finds the largest circle in that triangular region. So he gets something like this (Please click here for a black-and-white version of the figure):

Mr Smith then plants yellow sunflowers, blue violets and red roses in the way shown in the figure. (Nice combination, eh? :-) Given the lengths of the three sides of the triangle, you are to find the areas of the regions with each kind of flowers respectively.

Input and Output

Each line of input contains three integers a, b, c, the lengths of the three sides of the triangular region, with 0 < abc ≤ 1000.

For each case, your program should output the areas of the regions with sunflowers, with violets and with roses respectively. Print your answers correct to 4 decimal places.

Sample Input

3 4 5

Sample Output

13.6350 2.8584 3.1416

Problemsetter: Mak Yan Kei

#include <stdio.h>
#include <math.h>

int main() {
    long long a, b, c;
    while(scanf("%lld %lld %lld", &a, &b, &c) == 3) {
        double roses, violets, sunflowers;
        double r, R, s = (a+b+c)/2.0;
        violets = sqrt(s*(s-a)*(s-b)*(s-c));
        r = violets*2/(double)(a+b+c);
        roses = r*r*acos(-1);
        R = a*b*c / 4.0 / violets;
        sunflowers = R*R * acos(-1) - violets;
        violets -= roses;
        printf("%.4lf %.4lf %.4lf\n", sunflowers, violets, roses);

    }
    return 0;
}