Given a triangle field and a rope of a certain length (Figure-1), you are required to use the rope to enclose a region within the field and make the region as large as possible.

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
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

题意:给你一个三角形的三个边,再给你一条长度为len的绳子.让你用绳子在三角形内圈出来一个区域让这个区域面积最大

思路:

我可以分类思考这个问题

1.如果绳子比三角形的周长还要长的话,最大的面积显然是这个三角形的面积

2.如果绳子很短呢?显然围成一个圆的时候面积是最大的.三角形里面最大的圆就是它的内切圆了

也就是说如果绳子的长度比三角形内切圆的周长还要小的时候,让它围成一个圆

3.当绳子介于1 2 的长度之间的呢?

当自由线从内切圆那种情况继续膨胀到能与三角形的边贴近但长度小于三角形周长时,将这个已经围成的面积划分为三个部分:
能构成一个更小的内切圆的三段弧,以三段弧的中心连结起来的一个更小且与原三角形相似的三角形,与原三角形贴近的三条边
所围成的三个矩形面积.

 #include <bits/stdc++.h>

 using namespace std;
#define eps 1e-9
#define pi acos(-1.0)
#define zero(x) (((x)>0?(x):-(x))<eps)
double a,b,c,len;
int main()
{
//freopen("de.txt","r",stdin);
int casee = ;
while (~scanf("%lf%lf%lf%lf",&a,&b,&c,&len)){
//len为自由线的长度;p0为原三角形的周长;p1为原三角形的半周长;
//R为原三角形的内切圆半径;r为相似三角形的内切圆半径。
if (zero(a+b+c+len))
break;
printf("Case %d: ",++casee);
double p0 = a+b+c;
double p1 = p0/;
double S = sqrt(p1*(p1-a)*(p1-b)*(p1-c));
double R = *S/p0;//三角形内切圆公式S=p0*R/2; R为内切圆半径
if (len>=p0)
{
printf("%.2f\n",S);
continue;
}
else if (*pi*R-len>eps){
R = len/pi/;
S = pi*R*R;
printf("%.2f\n",S);
continue;
}
else{
double r = (p0-len)/(p0/R-*pi);
//利用的就是三角形相似的原理;公式;p0/R*(R-r)=len-2*pi*r;左边是通过内切圆半径与周长的关系求
//得小三角形的周长;右边是通过自由线的长度减掉三段弧得到相似三角形的周长;
double radio = (R-r)/R;//相似比
a*=radio;
b*=radio;
c*=radio;
double p=(a+b+c)/;
S = pi*r*r+sqrt(p*(p-a)*(p-b)*(p-c))+r**p;
printf("%.2f\n",S);
continue; }
}
return ;
}

hdu 1451 Area in Triangle(计算几何 三角形)的更多相关文章

  1. POJ 1927 Area in Triangle(计算几何)

    Area in Triangle 博客原文地址:http://blog.csdn.net/xuechelingxiao/article/details/40707691 题目大意: 给你一个三角形的三 ...

  2. POJ 1927 Area in Triangle

    Area in Triangle Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 1674   Accepted: 821 D ...

  3. hdu 2528:Area(计算几何,求线段与直线交点 + 求多边形面积)

    Area Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submis ...

  4. hdu 2393:Higher Math(计算几何,水题)

    Higher Math Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...

  5. hdu 4709:Herding(叉积求三角形面积+枚举)

    Herding Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Sub ...

  6. hdu 2892 Area

    http://acm.hdu.edu.cn/showproblem.php?pid=2892 解题思路: 求多边形与圆的相交的面积是多少. 以圆心为顶点,将多边形划分为n个三角形. 接下来就求出每个三 ...

  7. HDU 3007 Buried memory(计算几何の最小圆覆盖,模版题)

    Problem Description Each person had do something foolish along with his or her growth.But,when he or ...

  8. POJ1927 Area in Triangle

      Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 1458   Accepted: 759 Description Give ...

  9. 2018 ICPC Asia Singapore Regional A. Largest Triangle (计算几何)

    题目链接:Kattis - largesttriangle Description Given \(N\) points on a \(2\)-dimensional space, determine ...

随机推荐

  1. __I、 __O 、__IO是什么意思?怎么用?

    出处:http://www.chuxue123.com/forum.php?mod=viewthread&tid=122&ctid=3 __I. __O .__IO是什么意思?这是ST ...

  2. C#-概念-类:类

    ylbtech-C#-概念-类:类 类(Class)是面向对象程序设计(OOP,Object-Oriented Programming)实现信息封装的基础.类是一种用户定义类型,也称类类型.每个类包含 ...

  3. sticky用法

    可以用于滚动到一定距离以后让他实现定位效果. 比如滚动到50px的时候让导航栏固定定位. 用法:给最外层的div设置绝对定位 然后要固定的div设置position:sticky; top:0: 这样 ...

  4. 【大前端攻城狮之路·二】Javascript&QA⼯程师

    今天给大家分享的主题的是Javascript&QA⼯程师.看到这个主题,可能有人问:前端开发完就OK了,剩下的丢给测试就行,哪里还需要关心这些?但事实上呢,测试是前端开发非常重要的环节,也是迈 ...

  5. HUD-2112 HDU Today(最短路map标记)

    题目链接:HUD-2112 HDU Today 思路: 1.最短路spfa模板. 2.map标记建图. 3.考虑距离为0或者-1的情况. 总结:下次map记得清空orz. AC代码: #include ...

  6. 基于K-means Clustering聚类算法对电商商户进行级别划分(含Octave仿真)

    在从事电商做频道运营时,每到关键时间节点,大促前,季度末等等,我们要做的一件事情就是品牌池打分,更新所有店铺的等级.例如,所以的商户分入SKA,KA,普通店铺,新店铺这4个级别,对于不同级别的商户,会 ...

  7. error LNK2019: unresolved external symbol __vsnwprintf

    老DX SDK,新VS2019问题,编译老项目GG,依赖库加入 legacy_stdio_definitions.lib 解决

  8. 数据库之Query Builder

    Yii的查询构造器提供了一个用面向对象的方法来构造SQL语句.他让开发人员可以用类的方法,属性来作为SQL语句的一部分.然后把不同部分组装到一个正确的SQL语句中,调用DAO的方法来执行.下面的例子演 ...

  9. Linux服务器安全配置小结(转)

    众所周知,网络安全是一个非常重要的课题,而服务器是网络安全中最关键的环节.Linux被认为是一个比较安全的Internet服务器,作为一种开放源代码操作系统,一旦Linux系统中发现有安全漏洞,Int ...

  10. seaborn教程2——颜色调控

    原文转载 https://segmentfault.com/a/1190000014966210 Seaborn学习大纲 seaborn的学习内容主要包含以下几个部分: 风格管理 绘图风格设置 颜色风 ...