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【求最大四边形面积】的更多相关文章

  1. bzoj1069: [SCOI2007]最大土地面积 凸包+旋转卡壳求最大四边形面积

    在某块平面土地上有N个点,你可以选择其中的任意四个点,将这片土地围起来,当然,你希望这四个点围成的多边形面积最大. 题解:先求出凸包,O(n)枚举旋转卡壳,O(n)枚举另一个点,求最大四边形面积 /* ...

  2. upc组队赛12 Cardboard Container【枚举】

    Cardboard Container Problem Description fidget spinners are so 2017; this years' rage are fidget cub ...

  3. python应用-已知三角形的边长求他的面积和周长

    """ 已知三角形的边长求他的面积和周长 Author:罗万财 Date:2017-3-3 """ import math a=float( ...

  4. JAVA求圆的面积

    import java.text.DecimalFormat;import java.util.Scanner; public class TheAreaOfCircle { public stati ...

  5. [ECNU 1624] 求交集多边形面积

    求交集多边形面积 Time Limit:1000MS Memory Limit:30000KB Total Submit:98 Accepted:42 Description 在平面上有两给定的凸多边 ...

  6. Just oj 2018 C语言程序设计竞赛(高级组)D: 四边形面积

    D: 四边形面积 时间限制: 1 s      内存限制: 128 MB      提交 我的状态 题目描述 有一个四边形,现在需要求它的面积 输入 输入四行,每行两个数整数xx, yy (1≤x,y ...

  7. python脚本1_给一个半径求圆的面积和周长

    #给一个半径,求圆的面积和周长,圆周率3.14 r = int(input('r=')) print('area='+str(3.14*r*r)) print('circumference='+str ...

  8. hdu-2036求任意多边形面积

    改革春风吹满地 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Sub ...

  9. YTU 2723: 默认参数--求圆的面积

    2723: 默认参数--求圆的面积 时间限制: 1 Sec  内存限制: 128 MB 提交: 206  解决: 150 题目描述 根据半径r求圆的面积, 如果不指定小数位数,输出结果默认保留两位小数 ...

随机推荐

  1. Html5 学习笔记 Sublime text3 和 Emmet 插件

    下载地址 :https://pan.baidu.com/s/1MpkaYdAcZd6RmPpmvOdK7w Emmet 压缩包 并且解压: 安装 Sublime Text 3, 选择首选项 浏览插件 ...

  2. 怎样理解Functor与Monad

    1. 复合函数操作符 Prelude> :t (.) (.) :: (b -> c) -> (a -> b) -> a -> c Prelude> (.) ( ...

  3. Selenium:八种元素定位方法

    前言: 我们在做WEB自动化时,最根本的就是操作页面上的元素,首先我们要能找到这些元素,然后才能操作这些元素.工具或代码无法像我们测试人员一样用肉眼来分辨页面上的元素.那么我们怎么来定位他们呢? 在学 ...

  4. IPython notebook在浏览器中显示不正常的问题及解决方法

    使用过Python的童鞋们应该知道IPython是一个比python自带的交互式界面更加友好的交互界面,IPython提供了自动补齐什么的,其实我还没开始用所以这里也不扯淡了,大家自己去网上查,IPy ...

  5. VS进程附加的使用

    一,附加进程(ctrl+alt+p)调试本地服务器接口(WCF,webapi等)的api 1>接口(WCF,webapi等)的api发布到本地IIS服务器,然后使用附加进程,将你发布的IIS添加 ...

  6. linux 命令 - ls(列出目录内容)

    ls - 列出目录内容 语法: ls (选项) (参数) 选项: -a:显示所有档案及目录(ls内定将档案名或目录名称为“.”的视为影藏,不会列出): -A:显示除影藏文件“.”和“..”以外的所有文 ...

  7. MMM实现Mysql高可用

    MySQL主主同步方案 l  MySQL主主+Keepalived l  MySQL+DRBD+Heartbeat 在企业中,数据库高可用一直是企业的重中之重,中小企业很多都是使用mysql主主方案, ...

  8. STL sort源码剖析

    转载自:http://www.cnblogs.com/imAkaka/articles/2407877.html STL的sort()算法,数据量大时采用Quick Sort,分段递归排序,一旦分段后 ...

  9. html使用字符串拼接js函数时传字符串参数

    <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...

  10. CNN基础一:从头开始训练CNN进行图像分类(猫狗大战为例)

    本文旨在总结一次从头开始训练CNN进行图像分类的完整过程(猫狗大战为例,使用Keras框架),免得经常遗忘.流程包括: 从Kaggle下载猫狗数据集: 利用python的os.shutil库,制作训练 ...