UVA10250 The Other Two Trees
来源:互联网 发布:python读音 编辑:程序博客网 时间:2024/06/05 04:06
Problem E
The Other Two Trees
Input: standard input
Output: standard output
Time Limit: 2 seconds
You have a quadrilateral shapedland whose opposite fences are of equal length. You have four neighbors whose landsare exactly adjacent to your four fences, that meansyou have a common fence with all of them. For example if you have a fence oflengthd in one side, this fence oflength d is also the fence of theadjacent neighbor on that side. The adjacent neighbors have no fence in commonamong themselves and their lands also don’t intersect. The main differencebetween their land and your land is that their lands are all square shaped. Allyour neighbors have a tree at the center of their lands. Given the Cartesiancoordinates of trees of two opposite neighbors, you will have to find theCartesian coordinates of the other two trees.
Input
Theinput file contains several lines of input. Each line contains four floatingpoint or integer numbersx1, y1, x2, y2,where (x1, y1), (x2, y2) are thecoordinates of the trees of two opposite neighbors. Input is terminated by endof file.
Output
For each line of input produce one line of output which contains theline “Impossible.” without thequotes, if you cannot determine the coordinates of the other two trees.Otherwise, print four floating point numbers separated by a single space withten digits after the decimal pointax1,ay1, ax2, ay2, where (ax1, ay1) and(ax2, ay2) are the coordinates of the other two trees. The output will bechecked with special judge program, so don’t worry about the ordering of thepoints 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
题目意思就是已知一个正方形对角线的两个点的坐标,求另外两个点的坐标。。
根据两个点的坐标,求出中点坐标坐标,在推一推就能等到公式了。。
x3 = (x1 + x2 +y2 - y1) / 2;
y3 = (y1 + y2 + x1 - x2) / 2;
x4 = (x1 + x2 - y2 + y1) / 2;
y4 = (y1 + y2 - x1 +x2) / 2;
AC代码:
#include<stdio.h>#include<cmath>int main () {double x1,y1,x2,y2,x3,y3,x4,y4;while (scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2) != EOF) {x3 = (x1 + x2 +y2 - y1) / 2;y3 = (y1 + y2 + x1 - x2) / 2;x4 = (x1 + x2 - y2 + y1) / 2;y4 = (y1 + y2 - x1 +x2) / 2;printf("%.10lf %.10lf %.10lf %.10lf\n",x3,y3,x4,y4);}return 0;}
- UVA10250-The Other Two Trees
- UVA10250 The Other Two Trees
- uva10250 The Other Two Trees
- UVA10250 The Other Two Trees
- UVA10250 The Other Two Trees
- UVA10250 - The Other Two Trees
- UVa10250 – The Other Two Trees
- The Other Two Trees
- The Other Two Trees
- 10250 - The Other Two Trees
- 10250 - The Other Two Trees
- 10250 The Other Two Trees
- 10250 - The Other Two Trees
- uva_10250 - The Other Two Trees
- UVA The Other Two Trees
- uva 10250 - The Other Two Trees
- uva-10250-The Other Two Trees
- Uva 10250 - The Other Two Trees
- Bluetooth in Android 4.2 and 4.3(一):综述
- 重要的手机短信丢失该怎么恢复
- 顺时针方向打印矩阵
- hao博文地址
- 9.5 触摸和手势:事件的传递的机制--演示代码
- UVA10250 The Other Two Trees
- uva 10250(数学)
- linux下文件打包和压缩
- [vim 小技巧] 在vim里保存只读文件
- dfs学习总结
- 链表(三)——链表删除冗余结点&插入结点到有序链表
- 堆和栈内存扩展方向问题
- hdu 2846 Repository
- Android 开发学习记录(3)---- httpclient使用(二)