Janitor Troubles

给定四个边,求所构成的四边形的最大面积用海伦公式

While working a night shift at the university as a janitor, you absentmindedly 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,s3s1,s2,s3 and s4s4, find the maximum area of any quadrilateral that can be constructed using these lengths. A quadrilateral is a polygon with four vertices.

Input

The input consists of a single line with four positive integers, the four side lengths s1s1, s2s2, s3s3, and s4s4.

It is guaranteed that 2si<∑4j=1sj2si<∑j=14sj, for all ii, and that 1≤si≤10001≤si≤1000.

Output

Output a single real number, the maximal area as described above. Your answer must be accurate to an absolute or relative error of at most 10−610−6.

#include<bits/stdc++.h>
using namespace std;
int main()
{
    double a,b,c,d;
    scanf("%lf%lf%lf%lf",&a,&b,&c,&d);
    double p=(a+b+c+d)/2;
    printf("%.15f\n",sqrt((p-a)*(p-b)*(p-c)*(p-d)));
    return 0;
}
 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值