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. Java连接MySql数据库之JDBC

    1.首先创建一个java Project项目 2.起一个英文的项目名 3.此窗口点击NO 4.此时项目状态如下 5.创建一个文件夹,并将mysql-connector-java-5.1.8-bin.j ...

  2. Mac下隐藏或显示文件/文件夹

    命令行操作 显示:defaults write com.apple.finder AppleShowAllFiles -bool true 隐藏:defaults write com.apple.fi ...

  3. 【转】时间序列分析——基于R,王燕

    <时间序列分析——基于R>王燕,读书笔记 笔记: 一.检验: 1.平稳性检验: 图检验方法:     时序图检验:该序列有明显的趋势性或周期性,则不是平稳序列     自相关图检验:(ac ...

  4. Linux运维工程师需掌握的技能

    笔者是运维工程师,对Linux方面有点心得,现在说一下需要掌握哪方面的工具吧.说到工具,在行外可以说是技能,在行内我们一般称之为工具,就是运维必须要掌握的工具.我就大概列出这几方面,这样入门就基本没有 ...

  5. Jmeter接口自动化培训

    课程前提 速成班,讲的不会非常深,每个人基础不一样,但是实现接口自动化没有问题,因为jmeter更多的用来做性能测试.当然有兴趣我们也可以穿插一点 课程基本大纲 接口基础概念 部署本地测试环境(使用d ...

  6. MySQL replace into 与insert into

    https://blog.csdn.net/helloxiaozhe/article/details/77427266 使用replace带来的问题 1.Replace into 操作在唯一键重复情况 ...

  7. jQuery DataTables 问题:Cannot reinitialise DataTable

    解决:  destroy: true, var tabel = $('#userlist').DataTable({        destroy: true,                    ...

  8. out.write()和out.print()区别,jsp注释区别

    out.write()和out.print()结果一样,都是输出内容 前者输出html内容 后者输出变量 5 JSP注释 我们现在已经知道JSP是需要先编译成.java,再编译成.class的.其中& ...

  9. [LeetCode] 182.查找重复的电子邮箱

    编写一个 SQL 查询,查找 Person 表中所有重复的电子邮箱. 示例: +----+---------+ | Id | Email | +----+---------+ | 1 | a@b.co ...

  10. SpringMvc.xml

    <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.sp ...