A Math Problem

来源:互联网 发布:海马玩mac安装失败 编辑:程序博客网 时间:2024/06/02 05:16

【Description】

 

   LittleMing今天碰到一道有趣的数学题,题目是这样的:在等边三角形ABC中,各边长度为1。D,E,F分别在边BC,AC,AB上,其中。

若给出的值,请求出三角形DEF的面积。

 

 

【Input】

 

第一行有一个数字CaseNumber,表示测试数据的组数。

每组测试数据有三个正数,分别为。三个正数都不超过20000.

 

【Output】

 

每组测试输出一个保留4为小数的浮点数(四舍五入),表示三角形DEF的面积。

 

 

 

 

 

【Sample Input】

 

3

1 1 1

1 2 3

2 2 2

 

【Sample Output】

 

0.1083

0.1263

0.1443

#include<iostream>#include<cstdio>#include<cmath>using namespace std;#define MAX(a,b) ((a)>(b) ? (a):(b))#define MIN(a,b) ((a)<(b) ? (a):(b))#define f(x1,x2) sqrt(((1+x2)*(1+x2)+x2*(1+x1)*(x1*x2-1))/((1+x1)*(1+x1)*(1+x2)*(1+x2)))int main(){int t;scanf("%d",&t);while(t--){double x1,x2,x3,p,a,b,c;scanf("%lf%lf%lf",&x1,&x2,&x3);a=f(x1,x2); b=f(x2,x3); c=f(x3,x1);p=(f(x1,x2)+f(x2,x3)+f(x3,x1))/2;printf("%.4lf\n",sqrt(p*(p-a)*(p-b)*(p-c)));}return 0;}


0 0