UVA-10250
The other and the Trees
Time Limit: 3000MS |
Memory Limit: Unknown |
64bit IO Format: %lld &%llu |
Submit Status
Description
Problem E
The other and the Trees
input: standard input
output: standard output
Time Limit: 2 seconds
You have a quadrilateral shaped land whose opposite fences is of equal length. You had four neighbors whose lands is exactly adjacent to your four fences, which means you had a common fence with all of them. For example if you had a fence of length D in one side, this fence of length D is also the fence of the Adjacent neighbor on that side. The adjacent neighbors has no fence in common among themselves and their lands also don ' t intersect. The main difference between their land and your land was that their lands was all square shaped. All your neighbors has a tree at the center of their lands. Given the Cartesian coordinates of trees of the opposite neighbors, you'll have to find the Cartesian coordinates of the Other trees.
Input
The input file contains several lines of input. Each line contains four floating point or integer numbers x1, y1, x2, y2, where (x1, y1), (x2, y2) is t He coordinates of the trees of the opposite neighbors. Input is terminated by end of file.
Output
For each line of input produce one line of output which contains the line "impossible." without the quotes, if yo U cannot determine the coordinates of the other and the trees. Otherwise, print four floating point numbers separated by a single space with ten digits after the decimal point ax1, Ay1, Ax2, Ay2, where (Ax1, Ay1) and (AX2, Ay2) is the coordinates of the other and the trees. The output would be is checked with special judge program, so don ' t worry about the ordering of the points or small precision Errors. The sample output would make it clear.
Sample Input
10 0-10 0
10 0-10 0
10 0-10 0
Sample Output
0.0000000000 10.0000000000 0.0000000000-10.0000000000
0.0000000000 10.0000000000-0.0000000000-10.0000000000
0.0000000000-10.0000000000 0.0000000000 10.0000000000
(World Final Warm-up Contest, problem Setter:shahriar Manzoor)
Source
Root:: Prominent problemsetters:: Shahriar Manzoor
Root:: AOAPC i:beginning algorithm Contests (Rujia Liu):: Volume 1. Elementary Problem Solving:: Maths-simple Geometry
Root:: Competitive programming 3:the New Lower Bound of programming contests (Steven & Felix Halim):: (Computationa L) Geometry:: Basic Geometry::P oints and Lines
Test instructions: Just give you the coordinates of the square two vertices to the top, and the coordinates of the other two vertices.
AC Code:
#include <cstdio> #include <cstring> #include <cmath> #include <algorithm>using namespace std; int main () {double x1, y1, x2, Y2;while (scanf ("%lf%lf%lf%lf", &x1, &y1, &x2, &y2)!=eof) {if (Fabs (x1-x2) &L T;1e-7 && fabs (y1-y2) <1e-7) {printf ("impossible.\n"); continue;} Double Midx, Midy, X3, Y3, X4, y4, T1, t2, K;midx = (x1 + x2)/2; Midy = (y1 + y2)/2;t1 = (X1-MIDX) * (X1-MIDX) + (y1-midy) * (y1-midy); k = (y1-y2)/(X1-X2); t2 = T1/(k*k + 1) for the slope of the line formed on the fixed point;
Uva-10250-the other Trees (Simple computational geometry)