Solution of 11152 - Colourful Flowers

Problem Description
source:https://uva.onlinejudge.org/external/111/11152.html

“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: 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 

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

Output 

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 


Solution:
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <deque>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include<stdio.h>
#include<stdlib.h>

using namespace std;

int main()
{
    double a,b,c;
    double s,area_bigc,big_r, small_r,area_t,sun,viol,ross;
    while(scanf("%lf%lf%lf",&a,&b,&c)==3)
    {
        s=(a+b+c)/2;
        area_t=sqrt(s*(s-a)*(s-b)*(s-c));
        big_r=(a*b*c)/(4*area_t);
        small_r=area_t/s;
        ross=4*atan(1)*small_r*small_r;
        viol=area_t-ross;
        area_bigc=4*atan(1)*big_r*big_r;
        sun=area_bigc-area_t;
        printf("%.4lf %.4lf %.4lf\n",sun,viol,ross);
    }
    return 0;
}

No comments:

Post a Comment

Write your comment - Share Knowledge and Experience