zoukankan      html  css  js  c++  java
  • UVA 10250 题目 The Other Two Trees (计算几何)

      类型:计算几何    (算法竞赛入门经典 P88 几何计算题)

    题目:

    Problem E

    The Other Two Trees

    Input: standard input

    Output: standard output

    Time Limit: 2 seconds

    You have a quadrilateral shaped land whose opposite fences are of equal length. You have four neighbors whose lands are exactly adjacent to your four fences, that means you have a common fence with all of them. For example if you 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 also don’t intersect. The main difference between their land and your land is that their lands are all square shaped. All your neighbors have a tree at the center of their lands. Given the Cartesian coordinates of trees of two opposite neighbors, you will have to find the Cartesian coordinates of 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. 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 you cannot determine the coordinates of the other two 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) are the coordinates of the other two trees. The output will be checked with special judge program, so don’t worry about the ordering of the points or small precision errors. The sample output will 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

     1 /*
     2 
     3 uva10250 题目: The Other Two Trees
     4 题目大意: 给出正方形两个点坐标求出另外两个点的坐标
     5 
     6 
     7 添平行于坐标轴的辅助线,作出全等三角形计算另外两个点的坐标
     8 
     9 */
    10 
    11 
    12 
    13 #include <cstdio>
    14 #include <cmath>
    15 using namespace std;
    16 
    17 int main()
    18 {
    19 
    20     double x1,y1,x2,y2;
    21 
    22     //freopen("in.txt","r",stdin);
    23     while(scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2)!=EOF)
    24     {
    25         double xm=0,ym=0;
    26 
    27         xm = (x1+x2)/2;
    28         ym = (y1+y2)/2;
    29 
    30         if(x1==x2 && y1==y2)
    31         {
    32             printf("“Impossible.”");
    33         }
    34         else
    35             printf("%.10f %.10f %.10f %.10f
    ",xm+y1-ym,ym+xm-x1,xm+y2-ym,ym+xm-x2);
    36 
    37     }
    38 
    39     return 0;
    40 }
  • 相关阅读:
    输入一个nxn矩阵各元素的值,球出两条对角线元素之和
    打印杨辉三角
    编写一个函数,实现两个字符串的连接功能
    字符串置换。将字符串s中的出现的字符s1用字符s2置换
    有一行文字,要求删去其中某个字符
    自定义函数delstr()的功能是删去字符串s1中所有的"*"
    用微软的kestrel在Linux上利用Apache架设Asp.Net Core环境
    2012年8月14日 星期二 equals()方法 (冲突备份)
    jquery 操作DOM 案例
    FileUpload 控件上传图片和文件
  • 原文地址:https://www.cnblogs.com/doubleshik/p/3357108.html
Copyright © 2011-2022 走看看