24h購物| | PChome| 登入
2012-04-28 15:04:04| 人氣1,068| 回應0 | 上一篇 | 下一篇

[UVA][Math] 11152 - Colourful Flowers

推薦 0 收藏 0 轉貼0 訂閱站台

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;
}

台長: Morris
人氣(1,068) | 回應(0)| 推薦 (0)| 收藏 (0)| 轉寄
全站分類: 不分類 | 個人分類: UVA |
此分類下一篇:[UVA][中國郵路問題] 10296 - Jogging Trails
此分類上一篇:[UVA][DP最大值最小化] 714 - Copying Books

是 (若未登入"個人新聞台帳號"則看不到回覆唷!)
* 請輸入識別碼:
請輸入圖片中算式的結果(可能為0) 
(有*為必填)
TOP
詳全文