Area in Triangle (计算几何)
来源:互联网 发布:猎趣钓鱼网站源码 编辑:程序博客网 时间:2024/06/05 06:19
input
The input has several sets of test data. Each set is one line containing four numbers separated by a space. The first three indicate the lengths of the edges of the triangle field, and the fourth is the length of the rope. Each of the four numbers have exactly four digits after the decimal point. The line containing four zeros ends the input and should not be processed. You can assume each of the edges are not longer than 100.0000 and the length of the rope is not longer than the perimeter of the field.
Output one line for each case in the following format:
Case i: X
Where i is the case number, and X is the largest area which is rounded to two digits after the decimal point.
sample input
12.0000 23.0000 17.0000 40.0000
84.0000 35.0000 91.0000 210.0000
100.0000 100.0000 100.0000 181.3800
0 0 0 0
sample output
Case 1: 89.35
Case 2: 1470.00
Case 3: 2618.00
这道题目的意思就是给你一个三角形和一根绳要求用绳在三角形内围出最大的面积。又是一道数学题目,今天脑袋很晕,只想做一定水题的,
不过这个题目想了一会,唯一要注意的是精度问题。参考了很多博客,不过有很多是不能AC的代码,很迷。
#include<cstdio>#include<cmath>#include<iostream>#include<algorithm>using namespace std;const double PI=acos(-1);int main(){double a,b,c,d,l,max,R,r,t,area;int count=1;scanf("%lf %lf %lf %lf",&a,&b,&c,&d);while(a+b+c+d){t=a+b+c;l=t*0.5;area=sqrt(l*(l-a)*(l-b)*(l-c));R=area*2.0/t;if(a+b+c<=d)max=area;else if(2.0*PI*R>=d)max=d*d/(4.0*PI);else{r=(a+b+c-d)/((a+b+c)/R-2.0*PI);max=area+PI*r*r-(r*r*area/(R*R));}printf("Case %d: %.2f\n",count++,max);scanf("%lf %lf %lf %lf",&a,&b,&c,&d);}}
- Area in Triangle(计算几何基础)
- Area in Triangle (计算几何)
- POJ 1927 Area in Triangle(计算几何)
- poj1654 Area (计算几何)
- poj1265 Area(计算几何)
- [POJ1654]Area(计算几何)
- [POJ1265]Area(计算几何)
- poj 1265 Area 计算几何Pick定理 && poj 2954 Triangle
- [POJ2954]Triangle(计算几何)
- Area in Triangle
- Area in Triangle(poj1927)
- poj 1654 Area(计算几何)
- POJ 1265 Area(计算几何--网格)
- POJ 1654 Area(计算几何)
- POJ 1654 Area(计算几何)
- HDU 1071 The area(计算几何)
- HDU 1071 The area(计算几何)
- hdu1071The area(计算几何)
- 筷子
- ROS发布&订阅字符串
- Vector,ArrayList,LinkedList的区别与适用场景
- 使用pymsql存取图片
- Docker中配置国内镜像
- Area in Triangle (计算几何)
- QGC中地图
- Number Sequence(不知道啥方法,不过做出来了,不容易啊)
- struts、hibernate、spring、 mybatis、 spring boot 等面试题汇总
- Android中定时执行任务的3种实现方法
- java性能优化之for循环
- zoj3705 Applications 模拟题
- android shape的使用详解
- ssh命令作为windows系统命令