Area in Triangle

博客原文地址:http://blog.csdn.net/xuechelingxiao/article/details/40707691

题目大意:

给你一个三角形的三边边长,给你一跟绳子的长度,将绳子放在三角形里围起来的面积最大是多少。

解题思路:

当然能够想到当绳子的长度十分长的时候,绳子能围城的最大面积就是三角形的面积。

当然还能够想到的是当绳子的长度比較短,小于三角形的内接圆的长度时,绳子能围城的面积就是绳子能围成的圆的面积。

那么剩下要计算的就是当绳子长度小于三角形周长而且大于三角形内接圆的时候。

这样的情况下,显然会是如图所看到的的情况。

那么这样的情况下的面积怎么计算呢?

如图:

两个三角形是相似的,所以红色绳子所围成部分的面积就是大三角形的面积减去小三角形的的面积再加上小三角形内切圆的面积,也就是代码中

ans = S-S*t*t+Pi*rr*rr; 的意义。至于小三角形内切圆的半径。则是用小三角形与大三角形相似算出来的比例求得的。

我感觉说的挺具体的,具体的看代码吧。

#include <map>
#include <set>
#include <stack>
#include <queue>
#include <vector>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <cstring>
#include <iostream>
#include <limits.h>
#include <algorithm>
#define LL long long
//#define LL long long
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define max3(a, b, c) (a>b?max(a, c):max(b, c))
#define min3(a, b, c) (a<b?min(a, c):min(b, c))
#define max4(a, b, c, d) max(max(a, b), max(c, d))
#define min4(a, b, c, d) min(min(a, b), min(c, d))
#define Read() freopen("data.in", "r", stdin);
#define Write() freopen("data.out", "w", stdout); const double Pi = acos(-1.0);;
const double Ee = 2.718281828459045235360;
const int INF = 0x3f3f3f3f;
const LL INFF = 0x3f3f3f3f3f3f3f3fLL;
const double eps = 1e-8;
const int MOD = 1000000009; const int dx4[] = {-1, 0, 1, 0};
const int dy4[] = { 0, 1, 0, -1};
const int dx8[] = {-1, 0, 1, 0, -1, -1, 1, 1};
const int dy8[] = {0 , 1, 0, -1, -1, 1, -1, 1};
const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1 , -1, 2, -2, 2, -2, 1, -1}; using namespace std; struct Point {
double x, y;
} P[20010], m; int dcmp(double x) {
return x < -eps ? -1 : x > eps;
} int main()
{
double a, b, c, d;
int icase = 1;
while(~scanf("%lf%lf%lf%lf", &a, &b, &c, &d)) {
if(dcmp(a)==0 && dcmp(b)==0 && dcmp(c)==0 && dcmp(d)==0) {
break;
}
double L = a+b+c;
double cosA = (b*b+c*c-a*a)/(2*b*c);
double S = 0.5*b*c*(sqrt(1-cosA*cosA));
double r = S*2/L;
double ans;
if(d > L) {
ans = S;
}
else if(2*Pi*r >= d) {
ans = d*d/(4*Pi);
}
else {
double t = (L-d)/(L-2*Pi*r);
double rr = r*t;
ans = S-S*t*t+Pi*rr*rr;
}
printf("Case %d: %.2lf\n", icase++, ans);
} return 0;
} /*test case*/
/* */

POJ 1927 Area in Triangle(计算几何)的更多相关文章

  1. POJ 1927 Area in Triangle

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

  2. POJ 1927 Area in Triangle 题解

    link Description 给出三角形三边长,给出绳长,问绳在三角形内能围成的最大面积.保证绳长 \(\le\) 三角形周长. Solution 首先我们得知道,三角形的内切圆半径就是三角形面积 ...

  3. 2018.07.04 POJ 1654 Area(简单计算几何)

    Area Time Limit: 1000MS Memory Limit: 10000K Description You are going to compute the area of a spec ...

  4. hdu 1451 Area in Triangle(计算几何 三角形)

    Given a triangle field and a rope of a certain length (Figure-1), you are required to use the rope t ...

  5. poj 1654 Area 多边形面积

    /* poj 1654 Area 多边形面积 题目意思很简单,但是1000000的point开不了 */ #include<stdio.h> #include<math.h> ...

  6. poj 1265 Area 面积+多边形内点数

    Area Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 5861   Accepted: 2612 Description ...

  7. POJ 1265 Area POJ 2954 Triangle Pick定理

    Area Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 5227   Accepted: 2342 Description ...

  8. 2018.07.04 POJ 1265 Area(计算几何)

    Area Time Limit: 1000MS Memory Limit: 10000K Description Being well known for its highly innovative ...

  9. POJ 1654 Area 计算几何

    #include<stdio.h> #include<string.h> #include<iostream> #include<math.h> usi ...

随机推荐

  1. Python自动化测试框架——概述

    #使用import import unittest #测试用例TestCase ''' 一个测试用例时一个完整的测试流程,包括了环境准备SetUp,测试执行Run,测试环境还原TearDown 一个测 ...

  2. VMware搭建内网并通过iptables端口转发联网

    整体流程图 配置Server1 新建两块网卡 一块网卡设置为桥接模式,另外一块设置为仅主机模式 查看两块网卡配置 root@ubuntu:~# ifconfig ens33 Link encap:Et ...

  3. CentOS 6.5 x64 安装MySql 5.6

    1.检测是否已经安装MySQL,输入以下命令 rpm -qa | grep mysql 如果存在,我们输入以下命令来删除 //强力删除 rpm -e --nodeps mysql 2.安装前环境准备 ...

  4. Ubuntu 配置Apache虚拟目录

    http://blog.csdn.net/spring21st/article/details/6589300 Ubuntu 配置Apache虚拟目录 http://blog.csdn.net/spr ...

  5. hexo干货系列:(八)hexo文章自动隐藏侧边栏

    前言 使用Jacman主题的时候发现打开具体文章后,侧边栏还是会展示,我想要的效果是自动隐藏侧边栏,并且展示目录.但是当我修改了主题配置文件里面close_aside属性为true的时候,发现侧边栏隐 ...

  6. NYOJ660逃离地球——只为最大存活率~

    逃离地球 时间限制:1000 ms  |  内存限制:65535 KB 难度: 描述 据霍金的<时间简史>所述,在几亿年之后将再次发生宇宙大爆炸.在宇宙大爆炸后,地球上将新生出许多生物而不 ...

  7. 理工个人积分赛最后一场(FZU)G - 五子棋,坑爹的大水题~~

    Problem 1490 五子棋 Time Limit: 1000 mSec Memory Limit : 32768 KB  Problem Description 五子棋是起源于中国古代的传统黑白 ...

  8. hdu 3879 最大密集子图(点和边均带权)(模板)

    /* 最大权闭合图,可以用最大密集子图来解速度更快复杂度低 题解:胡伯涛<最小割模型在信息学竞赛中的应用> 点和边均带权的最大密集子图 s-i,权为U=点权绝对值和+边的所有权值 i-t, ...

  9. BZOJ1703: [Usaco2007 Mar]Ranking the Cows 奶牛排名

    n<=1000头牛各有一个未知值Ai,已知m<=10000条形如Ax>Ay的不等关系,求将整个序列排序的最少比较次数. Aa>Ab,Ab>Ac -------> A ...

  10. ES6__变量的解构赋值

    /* 变量的解构赋值 */ /* 基本概念 : 本质上就是一种匹配模式,只要等号两边的模式相同,那么左边的变量就可以被赋予对应的值. 结构赋值主要分为: 1. 数组的解构赋值 2. 对象的结构赋值 3 ...