POJ 1927 Area in Triangle 题解
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 题解的更多相关文章
- POJ 1927 Area in Triangle
Area in Triangle Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 1674 Accepted: 821 D ...
- POJ 1927 Area in Triangle(计算几何)
Area in Triangle 博客原文地址:http://blog.csdn.net/xuechelingxiao/article/details/40707691 题目大意: 给你一个三角形的三 ...
- poj 1654 Area 多边形面积
/* poj 1654 Area 多边形面积 题目意思很简单,但是1000000的point开不了 */ #include<stdio.h> #include<math.h> ...
- poj 1265 Area 面积+多边形内点数
Area Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 5861 Accepted: 2612 Description ...
- poj 2431 Expedition 贪心 优先队列 题解《挑战程序设计竞赛》
地址 http://poj.org/problem?id=2431 题解 朴素想法就是dfs 经过该点的时候决定是否加油 中间加了一点剪枝 如果加油次数已经比已知最少的加油次数要大或者等于了 那么就剪 ...
- poj 1064 Cable master 二分 题解《挑战程序设计竞赛》
地址 http://poj.org/problem?id=1064 题解 二分即可 其实 对于输入与精度计算不是很在行 老是被卡精度 后来学习了一个函数 floor 向负无穷取整 才能ac 代码如下 ...
- ZOJ 4081 Little Sub and Pascal's Triangle 题解
ZOJ 4081 Little Sub and Pascal's Triangle 题解 题意 求杨辉三角第n行(从1开始计数)有几个奇数. 考察的其实是杨辉--帕斯卡三角的性质,或者说Gould's ...
- POJ 1265 Area POJ 2954 Triangle Pick定理
Area Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 5227 Accepted: 2342 Description ...
- POJ1927 Area in Triangle
Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 1458 Accepted: 759 Description Give ...
随机推荐
- E. Number With The Given Amount Of Divisors
E. Number With The Given Amount Of Divisors time limit per test 2 seconds memory limit per test 256 ...
- 1057 - Collecting Gold
1057 - Collecting Gold PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB ...
- idea使用教程-idea简介
集成开发环境(IDE,Integrated Development Environment )是用于提供程序开发环境的应用程序,一般包括代码编辑器.编译器.调试器和图形用户界面等工具.集成了代码编写功 ...
- 分析一个简单的goroutine资源池
分析一个简单的goroutine资源池 tunny. 从资源池中获取goroutine并进行处理的逻辑如下: tunny将goroutine处理单元封装为workWrapper,由此可以对gorout ...
- Atcoder ABC137D:Summer Vacation(贪心)
D - Summer Vacation Time Limit: 2 sec / Memory Limit: 1024 MB Score : 400 points Problem Statement T ...
- SOFA 通信
私有通信协议设计: 我们的分布式架构,所需要的内部通信模块,采用了私有协议来设计和研发. 可以有效地利用协议里的各个字段 灵活满足各种通信功能需求:比如 CRC 校验,Server Fail-Fast ...
- 【汇编语言】李忠《x86汇编语言——从实模式到保护模式》
该书配套资料网址已经失效 配套资料和章节答案下载 查看最新作者网址:http://www.lizhongc.com/ 勘误表:https://wenku.baidu.com/view/9213288b ...
- 当MySQL执行XA事务时遭遇崩溃,且看华为云如何保障数据一致性
摘要:当前MySQL所有版本不支持分布式事务的崩溃恢复安全,这严重影响了分布式事务的高可用保障. 华为云数据库内核高级技术专家,拥有十多年MySQL内核研发经验,目前在华为云数据库团队研发华为云数据库 ...
- [数据结果]C语言 基础指令汇编
数据结构 C语言核心操作集合 (1)预定义常量和类型 //函数结果状态代码 #define TRUE 1 #define FALSE 0 #define OK 1 #define ERROR 0 #d ...
- 【优雅代码】03-optional杜绝空指针异常
[优雅代码]03-optional杜绝空指针异常 欢迎关注b站账号/公众号[六边形战士夏宁],一个要把各项指标拉满的男人.该文章已在github目录收录. 屏幕前的大帅比和大漂亮如果有帮助到你的话请顺 ...