The areaTime
limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 8587 Accepted Submission (s): 6013
Problem Descriptionignatius 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-tell-Ignatius the area of the land?
Note:the Point P1 in the picture is the vertex of the parabola.
Inputthe input contains several test cases. The first line of the input was 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 is given in the order of P1, P2, P3. Each of the described by floating-point numbers X and Y (0.0<=x,y<=1000.0).
Outputfor the should output the area of the land, the result should is rounded to 2 decimal places.
Sample Input
25.000000 5.0000000.000000 0.00000010.000000 0.00000010.000000 10.0000001.000000 1.00000014.000000 8.222222
Sample Output
33.3340.69HintAccurate enough, please use double instead of float.Pure mathematical geometry calculation, mathematical slag, refer to the resolution of the great God to set the linear equation: Y=kx+t ..... ..... ... .... ..... ..... ..... ..... ..... ..... ..... ..... .....? ........ (1) Parabolic equation: Y=ax^2+bx+c ..... ... .... ..... ..... ..... ..... ..... ..... ..... ..... .... ..... .....???? ..... (2) Known parabolic vertex P1 (x1,y1), two line intersections P2 (x2,y2) and P3 (x3,y3) slope k= (y3-y2)/(X3-X2) ... ....... ..... .................. ......... (3) The P3 point into the (1) Type of combination (3) can be: t=y3-(K*X3) and because the P1 is the vertex of the parabola, can have a relationship: x1=-b/2a that b=-2a*x1 ... (4) The P1 point into the (2) type of combination (4) can be: a*x1*x1-2a*x1*x1+c=y1 c=y1+a*x1*x1 ... (5) The P2 point into the (2)-type combination (4) and (5) type can be obtained: a= (y2-y1)/((X1-X2) * (X1-X2)) and then through 3 points out k,t,a,b,c that two equations have been found to find the topic area s by integral: S=f (X2->X3) ( Integral symbol) (ax^2+bx+c-(kx+t)) =f (X2->X3) (integral symbol) (ax^2+ (b-k) x+c-t) =[a/3*x^3+ (b-k)/2*x^2+ (C-T) x] (x2- >X3) =a/3*x3*x3*x3+ (b-k)/2*x3*x3+ (C-T) *x3-(a/3*x2*x2*x2+ (b-k)/2*x2*x2+ (C-T) *x2) Simplification: Area formula: s=-(Y2-Y1)/((X2-x 1) * (X2-X1)) * ((X3-X2) * (x3-x2) * (X3-X2))/6;2015,7,20
#include <stdio.h>int main () {int t;double x1,x2,x3,y1,y2,y3,s;scanf ("%d", &t), while (t--) {scanf ("%lf%lf%lf %lf%lf%lf ", &x1,&y1,&x2,&y2,&x3,&y3), s= (y2-y1)/((x2-x1) * (X2-X1)) * ((X3-X2) * (x3-x2) * ( X3-X2))/6;printf ("%.2lf\n",-s);} return 0;}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
HDU 1071 the area