UVa 10250 The other two trees: computational geometry

Source: Internet
Author: User
Tags integer numbers time limit

10250-the other two Trees

Time limit:3.000 seconds

Http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=101&page=show_ problem&problem=1191

Have a quadrilateral shaped land whose opposite fences are of equal of length. You are have four neighbors whose lands are exactly adjacent to your four, which fences you means a have common and all of them. For example if your have 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 have no fence in common among themselves and their lands don ' t also. The main difference between their land and your are that their, lands all square are. All your neighbors have a is at the center of their lands. Given the Cartesian coordinates of trees of two opposite neighbors, you'll have to find the Cartesian coordinates the Other two 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) are the coordinates of The trees of two opposite neighbors. The Input is terminated by the end of file.

Output

For each line of input produce one line of output which contains "impossible." Without the quotes, if you cannot Determine the coordinates of the other two trees. Otherwise, print four floating point numbers separated through a single spaces with ten digits after the decimal point ax1, Ay1, AX2, Ay2, where (Ax1, ay1) and (AX2, ay2) are the coordinates of the other two trees. The output is checked with special judge and 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

Relative proximity of the median distance d1,d2 satisfies d1=d2 (proofs slightly)

Complete code:

/*0.032s*/
    
#include <cstdio>  
    
int main ()  
{  
    double x1, x2, y1, y2;  
    while (~SCANF ("%lf%lf%lf%lf", &x1, &y1, &x2, &y2))  
        printf ("%f%f%f%f\n", (x1 + x2 + y2-y1)/2, (x 1-x2 + y1 + y2)/2, (x1 + x2 + y1-y2)/2, (x2-x1 + y1 + y2)/2);  
    return 0;  
}

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/sjjg/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.