1305-area of a parallelogram
PDF (中文版) statisticsforum
Time Limit:1 second (s) Memory limit:32 MB
A parallelogram is a quadrilateral with the pairs of parallel sides. See the picture below:
Fig:a Parallelogram
Now is given the co ordinates of A, B and C, you have to find the coordinates of D and the area of the parallelogram. The orientation of ABCD should is same as in the picture.
Input
Input starts with an integer T (≤1000), denoting the number of test cases.
Each case starts with a line containing six integers ax, ay, Bx, by, Cx, Cy where (Ax, Ay) denotes the coordinate of a, (B x, by) denotes the coordinate of B and (Cx, Cy) denotes the coordinate of C. Value of any coordinate lies in the range [-1 000, 1000]. And you can assume A, B and C would not be collinear.
Output
For each case, print the case number and three integers where the first and the should is the coordinate of D and the third on E should is the area of the parallelogram.
Sample Input
Output for Sample Input
3
0 0 10 0 10 10
0 0 10) 0 10-20
-12-10 21 21 1 40
Case 1:0 10 100
Case 2:0-20 200
Case 3:-32 9 1247
#include <iostream>#include<cstdio>#include<cmath>using namespacestd;intMain () {intT,ax,ay,bx,by,cx,cy,dx,dy; scanf ("%d",&T); for(intt=1; t<=t;t++) {scanf ("%d%d%d%d%d%d",&ax,&ay,&bx,&by,&cx,&cy); DX= Cx-bx+ax,dy = cy-by+ay; intArea = ABS ((cy-by) * (AX-BX)-(ay-by) * (cx-bx)); printf ("Case %d:%d%d%d\n", T,dx,dy,area); //In this writing, remember to convert the ABS () type, otherwise WA//printf ("Case%d:%d%d%d\n", T,dx,dy, (int) abs ((cy-by) * (AX-BX)-(ay-by) * (CX-BX))); } }
Lightoj-1305-area of a parallelogram (geometry)