设为首页 加入收藏

TOP

In-circles Again(简单几何)
2015-11-21 01:04:27 来源: 作者: 【 】 浏览:1
Tags:In-circles Again 简单 几何

In-circles Again

Time Limit: 1000ms Memory Limit: 65536KB 64-bit integer IO format: %lld Java class name: Main Submit Status PID: 4272 In the figure below you can see triangle ABC and its in-circle (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. \

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-point 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-point number which denotes the area of triangle ABC. This floating-point 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-point numbers for floating-point 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
  
    using namespace std; double r[5]; double fun(double r1,double r2) { return ((r1+r2)*(r1+r2)-(r1-r2)*(r1-r2)); } bool cmp(double p1,double p2) { return p1>p2; } int main() { int d=1; while (~scanf("%lf%lf%lf%lf",&r[0],&r[1],&r[2],&r[3]) && r[0]!=-1) { sort(r,r+4,cmp); // for (int i=0;i<4;i++) // printf("%lf ",r[i]); // printf("\n"); double a1 = sqrt(fun(r[0],r[1])); double x1 = (a1*r[1]*1.0)/(r[0]-r[1]); double a2 = sqrt(fun(r[0],r[2])); double x2 = (a2*r[2]*1.0)/(r[0]-r[2]); double a3 = sqrt(fun(r[0],r[3])); double x3 = (a3*r[3]*1.0)/(r[0]-r[3]); double aa1=(a1+x1)+(a2+x2),aa2=(a2+x2)+(a3+x3),aa3=(a1+x1)+(a3+x3); double q=(aa1+aa2+aa3)/2.0; double s= sqrt(q*(q-aa1)*(q-aa2)*(q-aa3)); printf("Case %d: %.2lf\n",d++,s); } return 0; }
  

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇Partition List -- leetcod 下一篇zoj 3778 Talented Chef 贪心

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: