In-circles Again(简单几何)
来源:互联网 发布:淘宝美工兼职怎么收费 编辑:程序博客网 时间:2024/06/06 18:51
In-circles Again
Given the values of r, r1, r2 and r3 you will have to find the area of triangle ABC.
Input
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.8019699761186.6830516757 71.9474500429 84.8796672233 37.6219288070-1 -1 -1 -1
Sample Output
Case 1: 18237.14Case 2: 195777.32
思路:#include<bits/stdc++.h>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;}
- In-circles Again(简单几何)
- In-circles Again (计算几何)
- In-circles Again(计算几何基础)
- In-circles Again
- POJ 3808 Malfatti Circles(计算几何)
- uva 11731 - Ex-circles(几何)
- uva 1447 - Malfatti Circles(几何+二分)
- ZOJ 1608 Two Circles and a Rectangle(简单计算几何)
- uva 375 Inscribed Circles and Isosceles Triangles 简单几何
- ACM-ICPC Asia Phuket Regional Programing Contest 2009---C:In-circles Again
- HDU 2876 Ellipse, again and again(几何求解)
- Ex-circles - UVa 11731 几何
- Malfatti Circles - POJ 3808 几何
- LightOJ Circle in Square (简单计算几何)
- CodeForces 372 E.Drawing Circles is Fun(计算几何+dp)
- uva 247 Calling Circles(Floyd 的简单应用)
- hdoj5563(简单几何)
- HDU4720(简单几何)
- 代码模板和编码的设置
- 【ASP.NET】——视频小结
- C#调用C++类
- 关于多线程的总结
- 个人作业
- In-circles Again(简单几何)
- HDU1050 Moving Tables 【模拟】
- VS集成Qt环境搭建
- ubuntu新建用户
- 有两个空酒桶,分别能舀3斤和7斤酒,还有1个装满了10斤的酒桶,我要卖5斤酒给剑客,这该如何是好?
- 我的ubuntu权限颜色
- iso 框架
- applicationContext.xml 配置说明
- C++中使用C#编写的类