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. Linux 中设置进程通过 systemctl 启动

    对于某些脚本或需要启动命令的程序,可以通过创建 xx.service 服务文件来使用 systemctl 控制. 例如,对于 docker-compose,其后台启动且忽略输出信息的命令为: $ no ...

  2. Vagrant 手册之网络 - 端口转发

    原文地址 Vagrantfile 配置文件中端口转发的网络标识符:forwarded_port,例如: config.vm.network "forwarded_port", gu ...

  3. Vagrant 入门 - 启动 vagrant 及 通过 ssh 登录虚拟机

    原文地址 在终端运行 vagrant up 命令即可启动 Vagrant 环境: $ vagrant up 不到一分钟,命令就会执行完毕,运行 Ubuntu 的虚拟机会启动成功.Vagrant 运行虚 ...

  4. log4j配置及异常、解决办法

    配置: ### set log levels ### D只有一个E也只有一个 log4j.rootLogger = debug,stdout,D,E ### 输出到控制台 ### log4j.appe ...

  5. MySQL5.7的搭建以及SSL证书

    Centos7 安装MySQL 5.7 (通用二进制包) 1.1  下载软件包 https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.17-l ...

  6. IDF-CTF-图片里的英语 writeup

    题目链接:http://ctf.idf.cn/index.php?g=game&m=article&a=index&id=34 一恒河沙中有三千世界,一张图里也可以有很多东西. ...

  7. JavaScript.InjectedScriptHost

    "use strict"; (function(InjectedScriptHost, inspectedGlobalObject, injectedScriptId) {     ...

  8. Flutter 仿滴滴出行App

    绿色出行 Flutter 仿滴滴出行App 地图:采用高德地图,仅简单完成了部分功能,基础地图,地址检索,逆地理编码. 界面:仿滴滴主界面,地图中心请求动效果,服务tabs展开效果,地址检索界面,城市 ...

  9. Sunday 字符串匹配算法(C++实现)

    简介: Sunday算法是Daniel M.Sunday于1990年提出的一种字符串模式匹配算法.其核心思想是:在匹配过程中,模式串并不被要求一定要按从左向右进行比较还是从右向左进行比较,它在发现不匹 ...

  10. git-vi

    VI命令可以说是Unix/Linux世界里最常用的编辑文件的命令了,但是它的命令集太多,所以要想精通他,也是一件很不容易的事情,除了专业SA,对于我们开发人员而已只需要掌握一些最最常见的用法应该就可以 ...