link

Description

给出三角形三边长,给出绳长,问绳在三角形内能围成的最大面积。保证绳长 \(\le\) 三角形周长。

Solution

首先我们得知道,三角形的内切圆半径就是三角形面积 \(\times 2\) 除以三角形周长。

可以看出,如果绳长 \(\le\) 三角形内切圆周长,那么我们肯定是围成一个圆。否则,我们就会围成下图形状:

考虑计算面积:

可以发现的是图中所指出的形状相等,以及小三角形与大三角形相似。那么我们就可以联立方程,解出小圆的半径,然后就可以算了。

Code

#include <cmath>
#include <cstdio>
#include <iostream>
using namespace std; #define Int register int
#define MAXN template <typename T> inline void read (T &t){t = 0;char c = getchar();int f = 1;while (c < '0' || c > '9'){if (c == '-') f = -f;c = getchar();}while (c >= '0' && c <= '9'){t = (t << 3) + (t << 1) + c - '0';c = getchar();} t *= f;}
template <typename T,typename ... Args> inline void read (T &t,Args&... args){read (t);read (args...);}
template <typename T> inline void write (T x){if (x < 0){x = -x;putchar ('-');}if (x > 9) write (x / 10);putchar (x % 10 + '0');}
template <typename T> inline void chkmax (T &a,T b){a = max (a,b);}
template <typename T> inline void chkmin (T &a,T b){a = min (a,b);} double a,b,c,d,pi = acos (-1); signed main(){
int cnt = 0;
while (~scanf ("%lf%lf%lf%lf",&a,&b,&c,&d)){
if (a + b + c + d == 0) return 0;
printf ("Case %d: ",++ cnt);
double L = a + b + c,t = L / 2,S = sqrt (t * (t - a) * (t - b) * (t - c)),R = S / t;
if (d <= 2 * pi * R) printf ("%.2f\n",d * d / (4 * pi));
else{
double r = (L - d) / (L / R - 2 * pi),l = L - (d - 2 * pi * r),s = l * r / 2;
printf ("%.2f\n",S - s + r * r * pi);
}
}
return 0;
}

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(计算几何)

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

  3. poj 1654 Area 多边形面积

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

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

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

  5. poj 2431 Expedition 贪心 优先队列 题解《挑战程序设计竞赛》

    地址 http://poj.org/problem?id=2431 题解 朴素想法就是dfs 经过该点的时候决定是否加油 中间加了一点剪枝 如果加油次数已经比已知最少的加油次数要大或者等于了 那么就剪 ...

  6. poj 1064 Cable master 二分 题解《挑战程序设计竞赛》

    地址 http://poj.org/problem?id=1064 题解 二分即可 其实 对于输入与精度计算不是很在行 老是被卡精度 后来学习了一个函数 floor 向负无穷取整 才能ac 代码如下 ...

  7. ZOJ 4081 Little Sub and Pascal's Triangle 题解

    ZOJ 4081 Little Sub and Pascal's Triangle 题解 题意 求杨辉三角第n行(从1开始计数)有几个奇数. 考察的其实是杨辉--帕斯卡三角的性质,或者说Gould's ...

  8. POJ 1265 Area POJ 2954 Triangle Pick定理

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

  9. POJ1927 Area in Triangle

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

随机推荐

  1. MySQL中视图的定义、原理--触发器

    视图概述 视图是一个虚拟表,其内容由查询定义.同真实的表一样,视图包含一系列带有名称的列和行数据.但是,视图并不在数据库中以存储的数据值集形式存在.行和列数据来自由定义视图的查询所引用的表,并且在引用 ...

  2. 面试中问你MySql,这一篇就够了

    说一说主键索引与唯一索引 主键是一种约束,唯一索引是一种索引,两者在本质上是不同的. 主键索引默认是聚簇索引.唯一索引一般是非聚簇索引. 主键索引不能为空,唯一索引在InnoDB中可以出现多个null ...

  3. 2048 双人创新小游戏【JavaFX-FXGL游戏框架】

    一个 uml 课程的大作业,项目要求设计并开发一款 2048 与某种游戏类型相结合的创新游戏.可以选择只建模或者既建模又实现,既然要做当然是选择实现啦(虽然没有接触过游戏...期末周的莽冲hhh,小组 ...

  4. PHP DateTime类常用方法总结

    实例化: $date = new DateTime(); $date = new DateTime('2018-01-01'); $date = new DateTime('tomorrow'); $ ...

  5. linux 之 误删openssl文件夹重装openssl

    背景 使用 scp.ssh 都报错 error while loading shared libraries: libcrypto.so.1.0.0: cannot open shared objec ...

  6. postgresql使用pg_dump工具进行数据库迁移

    一.使用管理员身份打开cmd,切换到postgresqlp安装目录下的bin目录 必须要以管理员身份打开cmd,否则报拒绝访问 二.把生成的文件上传到服务器上,同样cd 到postgresql的安装b ...

  7. Shell 中的 expect 命令

    目录 expect 介绍 expect 安装 expect 语法 自动拷贝文件到远程主机 示例一 示例二 示例三 示例四 expect 介绍 借助 expect 处理交互的命令,可以将交互过程如 ss ...

  8. PowerShell【IF篇】

    1 [int]$num=0 2 do 3 { 4 $num+=1 5 if($num%2) 6 { 7 "$num"+" 是奇数" 8 }else{ 9 &qu ...

  9. [login] 调用失败 Error: errCode: -404011 cloud function execution error | errMsg: cloud.callFunction:fail requestID , cloud function service error code -501000, error message Environment not found;

    按照微信开放文档,创建完云开发项目,运行,点击获取openid,报如下错: [login] 调用失败 Error: errCode: -404011 cloud function execution ...

  10. 使用Swing的GUI编程

    Swing AWT概述 AWT:抽象窗口工具包,提供了一套与本地图形界面进行交互的接口,是Java提供的用来建立和设置Java的图形用户界面的基本工具 Swing以AWT为基础的,尽管Swing消除了 ...