Problem Description
Ignatius bought a land last week, but he didn't know the area of the land because the land is enclosed by a parabola and a straight line. The picture below shows the area. Now given all the intersectant points shows in the picture, can you tell Ignatius the area of the land?
Note: The point P1 in the picture is the vertex of the parabola.
Note: The point P1 in the picture is the vertex of the parabola.
Input
The input contains several test cases. The first line of the input is a single integer T which is the number of test cases. T test cases follow. Each test case contains three intersectant points which shows in the picture, they are given in the order of P1, P2, P3. Each point is described by two floating-point numbers X and Y(0.0<=X,Y<=1000.0).
Output
For each test case, you should output the area of the land, the result should be rounded to 2 decimal places.
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
1 /* 2 看图直接能看出来这是X-区域,X-区域的积分公式是 3 b Q2(x) 4 ∫ dx∫ 1*dy 5 a Q1(x) 6 先对y积分,然后对y积分,y的积分上下限是两个函数 7 /* 8 由图可知 9 a=x2 10 b=x3 11 Q1(x)=过p1,p2两点的直线方程 12 Q2(x)=抛物线方程 13 */ 14 /* 15 我尼玛把抛物线顶点公式给忘了- -白活了 16 顶点 (h,b) 抛物线 y=a(x-h)^2+b 17 所以Q2(x)=((y2-y1)/(x2-x1)^2)*(x-x1)^2+y1 18 Q1(x)=(y3-y2)/(x3-x2)*x+y2-(y3-y2)/(x3-x2)*x2 19 */ 20 #include <cstdio> 21 int main() 22 { 23 int n; 24 double x1,y1,x2,y2,x3,y3; 25 scanf("%d",&n); 26 while(n--) 27 { 28 scanf("%lf%lf",&x1,&y1); 29 scanf("%lf%lf",&x2,&y2); 30 scanf("%lf%lf",&x3,&y3); 31 double a=(y2-y1)/((x2-x1)*(x2-x1)); 32 double b=-2*a*x1; 33 double c=a*x1*x1+y1; //这个数据浪费了我40分钟,艹 34 double k=(y3-y2)/(x3-x2); 35 double t=y2-k*x2; 36 // x3 37 // s=∫ Q2(x)-Q1(x) dx 38 // x2 39 double s=a/3*(x3*x3*x3-x2*x2*x2)+(c-t)*(x3-x2)+0.5*(b-k)*(x3*x3-x2*x2); 40 printf("%.2lf ",s); 41 } 42 return 0; 43 }