#include <stdio.h> typedef struct { double x,y; }Point; double area(Point p1, Point p2, Point p3) { double a, b, c; // 抛物线的参数 double k, h; // 直线的参数 double s; // 抛物线 y = ax^2 + bx + c a = (p2.y - p1.y) / ((p2.x - p1.x)*(p2.x - p1.x)); // a = (y2-y1) / (x2-x1)^2 b = -2 * a * p1.x; // b = -2a*x1; //c = p1.y - a * p1.x * p1.x - b * p1.x; // c = y - ax^2 - bx c=a*p1.x*p1.x+p1.y; //直线 y = kx + h k = (p2.y - p3.y) / (p2.x - p3.x); h = p3.y - k * p3.x; s = a/3*(p3.x*p3.x*p3.x - p2.x*p2.x*p2.x) + (b-k)/2*(p3.x*p3.x-p2.x*p2.x) + (c-h)*(p3.x-p2.x); return s; } int main(){ Point p1, p2, p3; int T; scanf("%d", &T); while(T--) { scanf("%lf %lf", &p1.x, &p1.y); scanf("%lf %lf", &p2.x, &p2.y); scanf("%lf %lf", &p3.x, &p3.y); printf("%.2lf\n", area(p1,p2,p3)); } return 0; } /* 注意:p1是抛物线顶点,利用 y= a(x-x1)^2+y1,求出a,再利用 b/(-2a)=x1,求出b, 实际上根据最值公式求出 c=a*x1^2+y1 */