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. P1753HackSon的趣味题

    1 #include<stdio.h> 2 #include<algorithm> 3 #include<iostream> 4 #include<stdli ...

  2. PowerDotNet平台化软件架构设计与实现系列(10):文件平台

    很多业务系统少不了需要进行文件管理,比如各种图片.excel.pdf.压缩包等等,为了高度可复用,我们抽象出文件平台,加强对文件进行管理. PowerDotNet文件平台目前支持阿里云OSS.Fast ...

  3. fork之后,子进程从父进程那继承了什么(转载)

    转载自:https://blog.csdn.net/xiaojun111111/article/details/51764389 知道子进程自父进程继承什么或未继承什么将有助于我们.下面这个名单会因为 ...

  4. Obfuscated Gradients Give a False Sense of Security: Circumventing Defenses to Adversarial Examples

    目录 概 主要内容 Obfuscated Gradients BPDA 特例 一般情形 EOT Reparameterization 具体的案例 Thermometer encoding Input ...

  5. pod内执行kill -3 pid

    1.使用logs命令监控输出 kubectl logs iothub2-iop-dm-replicaset-0   -n iot  -f  >> yuanqianqian.txt 2.在p ...

  6. Oracle的dbf文件迁移

    1.背景说明 在Oracle数据库中插入了1.5亿条数据, 并且创建了主键索引, 又插入了1.5亿条数据到另外一张表, 导致数据库表空间暴涨到28G, 由于根目录下只有50G的空间, 数据库文件所在磁 ...

  7. ElasticSearch+Kibana安装部署

    在安装ElasticSearch时遇到了很多坑,所以在这里做个笔记记录一下. 首先我考虑的是使用docker进行部署,结果发现虚拟机直接内存溢出,我也是无解了,也就是说使用docker部署还得注意容器 ...

  8. 【Warrior刷题笔记】剑指offer 6 24 35. 三道题,让你学会链表递归迭代辅助栈

    题目一 从尾到头打印链表 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/cong-wei-dao-tou-da-yin-lian-biao-l ...

  9. 数三角count(归类)

    评测方式:文本比较 题目描述 这是一个数三角的游戏.长度为1或SQRT(2)的小木棍放在一个网格上.如图所示,有水平的,垂直的或对角的.对角放置的木棍可以交叉. avatar 将木棍随意地放在网格上得 ...

  10. 总结关于spring security 使用 JWT 和 账户密码登录 整合在一起的新感悟

    (1)jwt登录拦截,需要在账户密码认证之前进行jwt认证,因此jwt拦截需要在 UsernamePasswordAuthenticationFilter 之前: (2)jwt验证通过则不需要执行账户 ...