当前位置: 代码迷 >> 综合 >> HDU--1071--the area
  详细解决方案

HDU--1071--the area

热度:68   发布时间:2023-12-12 06:46:37.0

//难点在于步骤繁琐!!!

#include<iostream>
using namespace std;
int main(){double x1,y1,x2,y2,x3,y3;//x1,y1是顶点!!double a,b,c,d,h;int t;cin>>t;while(t--){cin>>x1>>y1;cin>>x2>>y2;cin>>x3>>y3;h=x1;b=y1;a=(y2-b)/((x2-h)*(x2-h));c=(y2-y3)/(x2-x3);d=y2-c*x2;double ans=(1/3.0)*a*(x2*x2*x2-x3*x3*x3)-(1/2.0)*(2*a*h+c)*(x2*x2-x3*x3)+(a*h*h+b-d)*(x2-x3);if(ans>=0)printf("%.2f\n",ans);elseprintf("%.2f\n",-ans);} 
}


/*Sample Input
2
5.000000 5.000000
0.000000 0.000000
10.000000 0.000000
10.000000 10.000000
1.000000 1.000000
14.000000 8.222222
Sample Output
33.33
40.69
*/ 

  相关解决方案