Rancher Seunghwan Baek's Gift
Time limit1sMemory limit128 MB
Given a convex quadrilateral, compute five sub-region areas formed by connecting vertices to midpoints of the opposite sides plus the perimeter of the central quadrilateral, using geometry formulas.
- Level
Medium6 of 10
- Topics
- Geometry, Implementation, Math
- Solved
- No attempts yet
Problem
Rancher Seunghwan Baek owns a convex quadrilateral plot whose vertices, in counterclockwise order, are A, B, C, and D. He wants to give the four outer triangular pieces to his sons Baekwon, Baekjo, Baeksu, and Baeksuk, and the central quadrilateral to his daughter Baekmi for a vegetable garden.
Point A is always (0, 0), and point B is always (x, 0). Let A', B', C', and D' be the midpoints of sides BC, CD, DA, and AB, respectively. Draw segments AA', BB', CC', and DD'.
Baekwon receives the triangle bounded by side AB and segments AA' and BB'. Baekjo receives the triangle bounded by side BC and segments BB' and CC'. In the same way, Baeksu and Baeksuk receive the triangles adjacent to sides CD and DA. The quadrilateral formed in the center by the four segments is Baekmi's vegetable garden.
Find the five land areas and the length of the fence needed around Baekmi's garden.
Input
The first line contains the number of test cases T (1 <= T <= 1,000). Each test case consists of five real numbers x_B, x_C, y_C, x_D, y_D. They are, in order, the x-coordinate of B, the x- and y-coordinates of C, and the x- and y-coordinates of D. The given quadrilateral is always convex.
Output
For each test case, print one line containing the areas received by Baekwon, Baekjo, Baeksu, Baeksuk, and Baekmi in that order, followed by the fence length for Baekmi's garden. Print each of the five areas to exactly three digits after the decimal point, and print the fence length as an integer rounded up.