• 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
    ",x)
    #define pri2(x,y) printf("%d %d
    ",x,y)
    #define pri3(x,y,z) printf("%d %d %d
    ",x,y,z)
    #define prl(x) printf("%lld
    ",x)
    #define prl2(x,y) printf("%lld %lld
    ",x,y)
    #define prl3(x,y,z) printf("%lld %lld %lld
    ",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
    ",sum);
        return 0;
    }
    
    
  • 相关阅读:
    最近这段时间我,想在2008 的基础上,写2011 有的工具 不知道会样,这次又机会研究ploy
    Screen 可以查找屏幕pos系类的函数
    笔记1
    Ubuntu下如何安装 tar.bz2 文件
    安装ubuntu遇到“BusyBox”问题
    android luancher 如何添加快捷方式
    转 Android 源代码结构
    修改apk图标
    Linux Ubuntu 下如何安装 .SH文件
    解放你的电源键!!不用刷机不用装软件!超简单修改搜索锁屏、HOME键唤醒~~~~~
  • 原文地址:https://www.cnblogs.com/llke/p/10787142.html
Copyright © 2020-2023  润新知