Construct a matrix of coefficients, remove the Gaussian element to solve the quadratic function, and then calculate the linear function in two ways, and bring it to the brainless AC by the Simpson integration method...
# Include <cstdio> # include <queue> # include <algorithm> # include <cstring> # include <vector> # include <cmath> using namespace STD; struct node {Double X, y;} p [4]; double G [10] [10]; double F1 (Double X) // quadratic function {return G [0] [3] * x + G [1] [3] * x + G [2] [3];} double F2 (Double X) // two-point straight line {double y2 = P [2]. y, X2 = P [2]. x; double Y1 = P [1]. y, X1 = P [1]. x; Return (x-x1)/(x2-x1) * (y2-y1) + Y1;} double F (Double X) {return F1 (x)-F2 (x);} double simp Son (double A, double B, int N) {double H = (B-a)/n; double ans = f (a) + F (B ); for (INT I = 1; I <n; I + = 2) ans + = 4 * f (a + I * H); For (INT I = 2; I <n; I + = 2) ans + = 2 * f (a + I * H); Return ans * H/3;} void Gauss (INT CNT) {int I, j, k; double TMP, big; for (I = 0; I <CNT; I ++) {for (big = 0, j = I; j <CNT; j ++) {If (FABS (G [J] [I])> big) {big = FABS (G [J] [I]); k = J ;}} if (K! = I) {for (j = 0; j <= CNT; j ++) Swap (G [I] [J], G [k] [J]);} for (j = I + 1; j <CNT; j ++) {If (G [J] [I]) {TMP =-G [J] [I]/g [I] [I]; for (k = I; k <= CNT; k ++) G [J] [k] + = TMP * g [I] [k] ;}}for (I = CNT-1; I> = 0; I --) {for (j = I + 1; j <CNT; j ++) G [I] [CNT]-= G [J] [CNT] * g [I] [J]; G [I] [CNT]/= G [I] [I] ;}} int main () {int CAS; scanf ("% d", & CAS ); while (CAS --) {for (INT I = 0; I <3; I ++) scanf ("% lf", & P [I]. x, & P [I]. y); For (INT I = 0; I <3; I ++) {G [I] [0] = P [I]. x * P [I]. x; // ax ^ 2G [I] [1] = P [I]. x; // bx g [I] [2] = 1; // c g [I] [3] = P [I]. y; // y} Gauss (3); // printf ("% lfx ^ 2 + % lfx + % lf \ n", G [0] [3], G [1] [3], G [2] [3]); printf ("%. 2lf \ n ", Simpson (P [1]. x, p [2]. x, 1000);} return 0 ;}