24h購物| | PChome| 登入
2012-11-03 17:12:09| 人氣831| 回應0 | 上一篇 | 下一篇

[ACM-ICPC] 4714 - In-circles Again

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

In the figure below you can see triangle ABC and its in-苞ircle (Circle that touches all the sides of a triangle internally). The radius of this in circle is r. Three other circles are drawn. Each of them touches two sides of this triangle and the in circle of ABC. The radiuses of these circles are r1, r2 and r3.

epsfbox{p4714.eps}

Given the values of r, r1, r2 and r3 you will have to find the area of triangle ABC.

Input 

The input file can contain up to 1000 lines of inputs. Each line contains four positive floating-計oint numbers which denotes the values of r, r1, r2 and r3 respectively.

Input is terminated by a line containing four negative integers.

Output 

For each line of input produce one line of output. This line contains serial of output followed by a floating-計oint number which denotes the area of triangle ABC. This floating-計oint number may have two digits after the decimal point. You can assume that for the given values of r, r1, r2 and r3 it will always be possible to construct a triangle ABC. If required you can assume that $ pi$ = 3.141592653589793 and also use double precision floating-計oint numbers for floating-計oint calculations. You can assume that there will be no such input for which small precision errors will cause difference in printed output. Look at the output for sample input for details.

Sample Input 

49.1958415692 5.3025839959 20.7869367050 31.8019699761 
186.6830516757 71.9474500429 84.8796672233 
37.6219288070 
-1 -1 -1 -1

Sample Output 

Case 1: 18237.14 
Case 2: 195777.32


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

int main() {
double r, r1, r2, r3;
int cases = 0;
while(scanf("%lf %lf %lf %lf", &r, &r1, &r2, &r3) == 4) {
if(r < 0) break;
double p1, p2, p3, a, b, c;
p1 = r/(r-r1)*sqrt(pow(r+r1, 2)-pow(r-r1, 2));
p2 = r/(r-r2)*sqrt(pow(r+r2, 2)-pow(r-r2, 2));
p3 = r/(r-r3)*sqrt(pow(r+r3, 2)-pow(r-r3, 2));
a = p1+p2, b = p2+p3, c = p3+p1;
printf("Case %d: %.2lf", ++cases, (a+b+c)*r/2);
puts("");
}
return 0;
}
 

台長: Morris
人氣(831) | 回應(0)| 推薦 (0)| 收藏 (0)| 轉寄
全站分類: 不分類 | 個人分類: UVA |
此分類下一篇:[ACM-ICPC][搜索] 5723 - Water Gate Management
此分類上一篇:[ACM-ICPC] 4713 - Elias Omega Coding

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