Wednesday, April 27, 2016

Solution of UVA 11152 - Colourful Flowers

View the problem UVa-11152


#include<bits/stdc++.h>
#define pi acos(-1)
using namespace std;
int main()
{
    int a, b, c;
    while(scanf("%d%d%d", &a,&b,&c)!=EOF){
        double r, R, area_tri, area_cir, s, ans1, ans2, ans3;
        s=(a+b+c)/2.0;
        area_tri=sqrt(s*(s-a)*(s-b)*(s-c));
        R=(a*b*c)/(4*area_tri);
        area_cir=pi*R*R;
        ans1=area_cir-area_tri;
        r=area_tri/s;
        ans3=pi*r*r;
        ans2=area_tri-ans3;
        printf("%.4lf %.4lf %.4lf\n", ans1,ans2,ans3);
    }
    return 0;
}

No comments:

Post a Comment