joj 2575: Moveable quadrangle with three edges ()

來源:互聯網
上載者:User
文章目錄
  • Input
  • Output
  • Sample Input
  • Sample Output

Result TIME Limit MEMORY Limit Run Times AC Times JUDGE
3s 8192K 435 75 Standard

我們知道,四邊形是可以移動和不穩定的。給定三個相連的邊a,b和c,它們之間的夾角可以活動,第四條邊由兩邊的頂點虛擬連線構成,這個四邊形的面積隨不同的夾角變化。請找出最大的四邊形面積。

Input

輸入的每一行代表一個Case。每一行有三個正浮點數,分別是a,b,c。

Output

對於每一個輸入,計算最大的四邊形的面積。輸入四捨五入到小數點後4位。

Sample Input
1 1 1.01 2 1.0
Sample Output
1.29902.2018
/*
利用幾何關係找到當a b夾角固定時,c應當與ab邊所成三角形垂直時,面積最大,所以只需枚舉a b夾角就好(資料很水)。
*/

#include <cstdio>

#include <iostream>

#include <memory>

#include <cmath>

const int maxn = 1000;

const double pi=acos(-1.);

const double p=1e-5;

int main ()

{

    double a,b,c;

    while (scanf("%lf%lf%lf",&a,&b,&c)!=EOF)

    {

    double ans=0,r,tmp;

    for ( r=p ; r<pi ; r=r+p)

    {

        double d=sqrt(a*a+b*b-2*a*b*cos(r));

         tmp = a*b*sin(r)/2+d*c/2 ;

        if(ans<tmp)ans=tmp;

    }

    printf("%.4lf/n",ans);

    }

    return 0;

}

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.