UVA10250 The Other Two Trees

思路:一开始按照高中的思路做一直错,后来用的向量旋转做的,可百度


#include<iostream>
#include<cstdio>
using namespace std;

int main()
{
    double x1,y1,x2,y2;
	while(scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2)!=EOF)
	{
		double x3=0,x4=0,y3=0,y4=0;
		if(x1==x2 &&y1==y2)
			printf("Impossible.\n");
        else
		{
			double mx = (x1+x2)/2;
			double my = (y1+y2)/2;
			x1-=mx;
			x2-=mx;
			y1-=my;
			y2-=my;
			x3=-y1;
			y3=x1;
			x4=-x3;
			y4=-y3;
			printf("%lf %lf %lf %lf\n",x3+mx,y3+my,x4+mx,y4+my);
		}
	}
}


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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值