[UVA][Math] 10991 - Region@Morris' Blog|PChome Online 人新台
2012-05-05 21:41:57| 人760| 回0 | 上一篇 | 下一篇

[UVA][Math] 10991 - Region

0 收藏 0 0 站台

Problem B
Region
Input: Standard Input

Output: Standard Output

 

From above figure, it is clear that C1, C2 and C3 circles are touching each other.

 

Consider,

 

            C1 circle have R1 radius.

            C2 circle have R2 radius.

            C3 circle have R3 radius.

 

Write a program that will calculate the area of shaded region G

 

Input

The first line will contain an integer k (1 ≤ k ≤ 1000) which is the number of cases to solve. Each of the following k Lines will contain three floating point number R1 (1 ≤ R1 ≤ 1000), R2 (1 ≤ R2 ≤ 1000) and R3 (1 ≤ R3 ≤ 1000).

 

Output

For each line of input, generate one line of output containing the area of G rounded to six decimal digits after the decimal point. Floating-point errors will be ignored by special judge program.

 

Sample Input       &nbs;                       Output for Sample Input

2

5.70 1.00 7.89

478.61 759.84 28.36

 

1.224323

2361.005761

 



犯下了大, asin 的是在 pi/2 ~ -pi/2
因此有, 所以要用 acos, 用弦定理

#include <stdio.h>
#include <math.h>
int main() {
    double r1, r2, r3, theta;
    double area, a, b, c, s, ans;
    int t;
    scanf("%d", &t);
    while(t--) {
        scanf("%lf %lf %lf", &r1, &r2, &r3);
        a = r1+r2, b = r2+r3, c = r3+r1;
        s = (a+b+c)/2;
        area = sqrt(s*(s-a)*(s-b)*(s-c));
        ans = area;
        theta = acos((a*a+c*c-b*b)/2/a/c);
        ans -= r1*r1*theta/2;
        theta = acos((a*a+b*b-c*c)/2/a/b);
        ans -= r2*r2*theta/2;
        theta = acos((b*b+c*c-a*a)/2/b/c);
        ans -= r3*r3*theta/2;
        printf("%lf\n", ans);
    }
    return 0;
}

 

台: Morris
人(760) | 回(0)| 推 (0)| 收藏 (0)|
全站分: 不分 | 人分: UVA |
此分下一篇:[UVA] 11650 - Mirror Clock
此分上一篇:[UVA][Math] 474 - Heads / Tails Probabilty

是 (若未登入"人新台"看不到回覆唷!)
* 入:
入片中算式的果(可能0) 
(有*必填)
TOP
全文
ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86