24h購物| | PChome| 登入
2013-08-23 17:08:03| 人氣1,542| 回應0 | 上一篇 | 下一篇

[UVA][向量] 10250 - The Other Two Trees

推薦 0 收藏 0 轉貼0 訂閱站台

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


(World Final Warm-up Contest, Problem Setter: Shahriar Manzoor)

題目描述:

有一個正方形,四個頂點放樹,給對角的兩棵樹座標,問另外兩棵樹的座標。

題目解法:

從對角兩棵的中心點,走半個法向量過去即可。


#include <stdio.h>

int main() {
    double x1, x2, y1, y2;
    while(scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2) == 4) {
        double cx, cy;
        double vx, vy;
        double vvx, vvy;
        cx = (x1+x2)/2;
        cy = (y1+y2)/2;
        vx = x2-x1;
        vy = y2-y1;
        vvx = -vy/2;
        vvy = vx/2;
        printf("%.10lf %.10lf %.10lf %.10lf\n", cx+vvx, cy+vvy, cx-vvx, cy-vvy);
    }
    return 0;
}


台長: Morris
人氣(1,542) | 回應(0)| 推薦 (0)| 收藏 (0)| 轉寄
全站分類: 教育學習(進修、留學、學術研究、教育概況) | 個人分類: UVA |
此分類下一篇:[UVA] 10357 - Playball !!!
此分類上一篇:[UVA] 886 - Named Extension Dialing

是 (若未登入"個人新聞台帳號"則看不到回覆唷!)
* 請輸入識別碼:
請輸入圖片中算式的結果(可能為0) 
(有*為必填)
TOP
詳全文