upc组队赛12 Janitor Troubles【求最大四边形面积】
Janitor Troubles
Problem Description
While working a night shift at the university as a janitor, you absent-mindedly erase a blackboard covered with equations, only to realize afterwards that these were no ordinary equations! They were the notes of the venerable
Professor E. I. N. Stein who earlier in the day solved the elusive maximum quadrilateral problem! Quick, you have to redo his work so no one noticed what happened.
The maximum quadrilateral problem is quite easy to state: given four side lengths s1, s2, s3 and s4, find the maxiumum area of any quadrilateral that can be constructed using these lengths. A quadrilateral is a polygon with four vertices.
Input
Input
The input consists of a single line with four positive integers, the four side lengths s1, s2, s3,and s4.
It is guaranteed that \(2Si < \sum_{j=1}^4Sj\), for all i, and that 1 ≤ si ≤ 1000.
Output
Output a single floating point number, the maximal area as described above. Your answer must be accurate to an absolute or relative error of at most \(10^{−6}\).
Sample Input
1 2 1 1
Sample Output
1.299038105676658
题意
给你四条边,求最大四边形面积
题解
婆罗摩笈多公式
\(S=\sqrt{(s-a)(s-b)(s-c)(s-d)}\)
其中 \(s = \frac{a+b+c+d}{2}\) 半周长
代码
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define scac(x) scanf("%c",&x)
#define pri(x) printf("%d\n",x)
#define pri2(x,y) printf("%d %d\n",x,y)
#define pri3(x,y,z) printf("%d %d %d\n",x,y,z)
#define prl(x) printf("%lld\n",x)
#define prl2(x,y) printf("%lld %lld\n",x,y)
#define prl3(x,y,z) printf("%lld %lld %lld\n",x,y,z)
#define ll long long
#define LL long long
inline ll read(){ll x=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;}
#define read read()
#define pb push_back
#define mp make_pair
#define P pair<int,int>
#define PLL pair<ll,ll>
#define PI acos(1.0)
#define eps 1e-6
#define inf 1e17
#define INF 0x3f3f3f3f
#define MOD 998244353
#define mod 1e9+7
#define N 2000005
const int maxn=2e5+5;
double a,b,c,d,sum,s;
int main()
{
scanf("%lf%lf%lf%lf",&a,&b,&c,&d);
s = (a+b+c+d)/2.0;
sum = sqrt((s-a)*(s-b)*(s-c)*(s-d));
printf("%.6lf\n",sum);
return 0;
}
upc组队赛12 Janitor Troubles【求最大四边形面积】的更多相关文章
- bzoj1069: [SCOI2007]最大土地面积 凸包+旋转卡壳求最大四边形面积
在某块平面土地上有N个点,你可以选择其中的任意四个点,将这片土地围起来,当然,你希望这四个点围成的多边形面积最大. 题解:先求出凸包,O(n)枚举旋转卡壳,O(n)枚举另一个点,求最大四边形面积 /* ...
- upc组队赛12 Cardboard Container【枚举】
Cardboard Container Problem Description fidget spinners are so 2017; this years' rage are fidget cub ...
- python应用-已知三角形的边长求他的面积和周长
""" 已知三角形的边长求他的面积和周长 Author:罗万财 Date:2017-3-3 """ import math a=float( ...
- JAVA求圆的面积
import java.text.DecimalFormat;import java.util.Scanner; public class TheAreaOfCircle { public stati ...
- [ECNU 1624] 求交集多边形面积
求交集多边形面积 Time Limit:1000MS Memory Limit:30000KB Total Submit:98 Accepted:42 Description 在平面上有两给定的凸多边 ...
- Just oj 2018 C语言程序设计竞赛(高级组)D: 四边形面积
D: 四边形面积 时间限制: 1 s 内存限制: 128 MB 提交 我的状态 题目描述 有一个四边形,现在需要求它的面积 输入 输入四行,每行两个数整数xx, yy (1≤x,y ...
- python脚本1_给一个半径求圆的面积和周长
#给一个半径,求圆的面积和周长,圆周率3.14 r = int(input('r=')) print('area='+str(3.14*r*r)) print('circumference='+str ...
- hdu-2036求任意多边形面积
改革春风吹满地 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Sub ...
- YTU 2723: 默认参数--求圆的面积
2723: 默认参数--求圆的面积 时间限制: 1 Sec 内存限制: 128 MB 提交: 206 解决: 150 题目描述 根据半径r求圆的面积, 如果不指定小数位数,输出结果默认保留两位小数 ...
随机推荐
- Php安装时出现的问题处理
问题从这里开始,我们一步一步说明: cd /usr/local/src/ tar zxvf php-5.5.6.tar.gz cd php-5.5.6 ./configure \ //执行当前目录下软 ...
- 小程序报错 Please do not register multiple Pages in undefined.js
在pages下面建了一个新页面的文件夹,但是没有在page.json里面注册,所以报了这个bug,注册一下就行了.
- 【Python—字典的用法】找到多个字典的公共键
有 a,b,c,d,e,f 6名球员,他们在三轮比赛中的进球数用 s1,s2,s3 3个字典表示,找到每轮都有进球的球员? 创建 s1,s2,s3 3个字典素材 from random import ...
- UILabel颜色逐渐变化
@interface UIViewController () @property (weak, nonatomic) IBOutlet UIView *backView; //空间是用storyBoa ...
- CentOS 7.3 环境配置java和tomcat开机启动
Centos7下添加开机自启动服务和脚本 https://blog.csdn.net/GMingZhou/article/details/78677953 安装部分参考我的博文,仅参考他的开机启动部 ...
- [Js代码风格]浅析模块模式
1.实例解释模块模式 简明扼要的说,经典的模块模式指的定义一个立即执行的匿名函数.在函数中定义私有函数和私有变量并且返回一个包含公共变量和公共函数作为属性和方法的匿名对象. var classicMo ...
- Goldengate 部署oracle10g在 rac asm环境,完整教程
前言 Goldengate再rac 环境部署,和单机部署区别还是有点大,主要存在环境上. 环境 oracle10g ,sid=rac 准备工作 1.在rac节点,配置监听动态注册,确保goldenga ...
- RIDE使用介绍
[转载] RIDE是一款专门用来编辑Robot Framework用例的软件,用Python编写并且开源.当我们针对一个系统编写好一套用例后,每当我们对系 统做一些更改的时候,便可以把已经写好的用例拿 ...
- 使用CSS3的@media来编写响应式的页面
首先要知道,我们为什么要写自适应的页面(响应式页面) [直接看干货] 众所周知,电脑.平板.手机的屏幕是差距很大的,假如在电脑上写好了一个页面,在电脑上看起来不错,但是如果放到手机上的话,那可能就会乱 ...
- bi包
闭包是函数式编程的概念 闭包的定义:由函数极其封闭的自由变量组成的集合体. 其实每一个函数都是一个闭包 特点:函数中嵌套函数. 在返回的时候不仅返回函数本身,而且返回内部函数的值,关键词‘释放’ 闭包 ...