还是读了很长时间的题,不过题本身很简单。

可以把四棵树想象成正方形的四个顶点,已知两个相对顶点的坐标,求另外两个坐标。

不过,原题可没直接这么说,中间需要一些小证明。

题中说有一个平行四边形然后分别以四条边为边长向外作正方形,四棵树就在四个正方形中心的位置。

这是我用几何画板画的图。

下面证△FOE≌△HGO

设CD=2a,BC=2b

∴EF=OH=a,

OF=HG=b

易知∠DFO=∠OHB

∴∠EFO=∠OHG=∠DFO+90°

∴△FOE≌△HGO(边角边)

∴∠E=∠GOH

∠EOG=∠EOF+∠DFO+∠E=90°      (因为再加上∠DFE就等于内角和180°了)

综上,OE=OG且OE⊥OG

由于对称性,四棵树就构成了个正方形。

下面说说算法,利用旋转。我是用复数做的。

比如说一个复平面的向量a+bi乘上i所得向量就是逆时针旋转90°所得向量,乘上-i就是顺时针。

可以计算出中点O的坐标,然后向量OG=Gx-Ox+(Gy-Oy)i,乘上单位向量i得Oy-Gy+(Gx-Ox)i。

在加上O的坐标就得到E的坐标(Ox+Oy-Gy,Oy-Ox+Gx)。

同理也可以很容易求出顺时针转90°后点的坐标。

10250

Problem E

The Other TwoTrees

Input: standard input

Output: standard output

Time Limit: 2 seconds

You have a quadrilateral(四边形) shaped land whose opposite fences are ofequal length(四边形对边相等,也就是平行四边形). You have four neighborswhose lands are exactly adjacent(邻近的) to your four fences, that means you have acommon fence with all of them. For example if you have a fence of length d inone side, this fence of length 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 difference between their land andyour land is that their lands are all square(正方形) shaped. All your neighbors have a tree at the center oftheir lands. Given the Cartesian coordinates(笛卡尔坐标) of trees of two opposite neighbors, you will have tofind the Cartesian coordinates of the other two trees.

Input

The input file contains several lines ofinput. Each line contains four floating point or integer numbers x1,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 ofoutput which contains the line “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 point ax1, ay1, ax2, ay2, where (ax1,ay1)  and (ax2, ay2) are the coordinates of the othertwo trees. The output will be checked with special judge program, so don’tworry about the ordering of the points or small precision errors. The sampleoutput will make it clear.

Sample Input

10 0 -10 0

10 0 -10 0

10 0 -10 0

Sample Output

0.000000000010.0000000000 0.0000000000 -10.0000000000

0.000000000010.0000000000 -0.0000000000 -10.0000000000

0.0000000000-10.0000000000 0.0000000000 10.0000000000


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

AC代码:

 //#define LOCAL
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std; int main(void)
{
#ifdef LOCAL
freopen("10250in.txt", "r", stdin);
#endif double x[], y[], midx, midy;
while(scanf("%lf %lf %lf %lf", &x[], &y[], &x[], &y[]) == )
{
midx = (x[] + x[]) / ;
midy = (y[] + y[]) / ;
x[] = midx + midy - y[];
y[] = x[] - midx + midy;
x[] = midx - midy + y[];
y[] = midx + midy - x[];
printf("%.10lf %.10lf %.10lf %.10lf\n", x[], y[], x[], y[]);
}
return ;
}

代码君

UVa 10250 The Other Two Trees的更多相关文章

  1. 【例题 6-17 UVa 10562】Undraw the Trees

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 模拟+递归 [代码] #include <bits/stdc++.h> using namespace std; con ...

  2. UVA题目分类

    题目 Volume 0. Getting Started 开始10055 - Hashmat the Brave Warrior 10071 - Back to High School Physics ...

  3. [LintCode]——目录

    Yet Another Source Code for LintCode Current Status : 232AC / 289ALL in Language C++, Up to date (20 ...

  4. (Step1-500题)UVaOJ+算法竞赛入门经典+挑战编程+USACO

    http://www.cnblogs.com/sxiszero/p/3618737.html 下面给出的题目共计560道,去掉重复的也有近500题,作为ACMer Training Step1,用1年 ...

  5. ACM训练计划step 1 [非原创]

    (Step1-500题)UVaOJ+算法竞赛入门经典+挑战编程+USACO 下面给出的题目共计560道,去掉重复的也有近500题,作为ACMer Training Step1,用1年到1年半年时间完成 ...

  6. 算法竞赛入门经典+挑战编程+USACO

    下面给出的题目共计560道,去掉重复的也有近500题,作为ACMer Training Step1,用1年到1年半年时间完成.打牢基础,厚积薄发. 一.UVaOJ http://uva.onlinej ...

  7. Uva 10007 / HDU 1131 - Count the Trees (卡特兰数)

     Count the Trees  Another common social inability is known as ACM (Abnormally Compulsive Meditation) ...

  8. UVA.122 Trees on the level(二叉树 BFS)

    UVA.122 Trees on the level(二叉树 BFS) 题意分析 给出节点的关系,按照层序遍历一次输出节点的值,若树不完整,则输出not complete 代码总览 #include ...

  9. UVa 10562 Undraw the Trees 看图写树

    转载请注明: 仰望高端玩家的小清新 http://www.cnblogs.com/luruiyuan/ 题目大意: 题目传送门:UVa 10562Undraw the Trees 给定字符拼成的树,将 ...

随机推荐

  1. 深入理解jQuery的Event机制

    jQuery的Event模块非常强大.其功能远远比原生事件监听器强大许多,对同一个元素的监听只用一个eventListener,内部则是一个强大的观察者,根据匹配事件类型触发相应回调.jQuery不仅 ...

  2. HDU 1316 How Many Fibs?(java,简单题,大数)

    题目 /** * compareTo:根据该数值是小于.等于.或大于 val 返回 -1.0 或 1: public int compareTo(BigInteger val) 将此 BigInteg ...

  3. Simulate a seven-sided die using only five-sided

    问题描述: 如题 转述一下问题,就是说你现在有一个正五面体骰子,然后你怎么用这个正五面体骰子去模拟一个正七面体骰子. 这个问题我接触到几种方法,下面一一阐述. 方法一: rand7()=( rand5 ...

  4. 安装软件(名称不记得了)后,系统开机提示 visual studio just-in-time debugger窗口(WINDOWS错误提示框)

    出现这种情况,往往是因为原先安装有VS,后来因某些原因(比如:卸载)导致VS无法使用!!当系统中的有些软件出现错误时,会自动调用vs进行调试,但因为VS无法使用,就出现了visual studio j ...

  5. JS事件驱动机制

    还记得当初学JAVA-GUI编程时学习过事件监听机制,此时再学习JavaScript中的事件驱动机制,不免简单.当初学习时也是画过原理图,所以从原理图开始吧! js是采用事件驱动(event-driv ...

  6. hdu 1536 S-Nim

    题意:首先输入K 表示一个集合的大小  之后输入集合 表示对于这对石子只能去除这个集合中的元素的 个数 之后输入一个m表示接下来对于这个集合要进行m次询问 之后m行 每行输入一个n 表示有  n个堆  ...

  7. TCP三次握手和四次挥手协议

    相对于SOCKET开发者,TCP创建过程和链接折除过程是由TCP/IP协议栈自动创建的.因此开发者并不需要控制这个过程.但是对于理解TCP底层运作机制,相当有帮助. TCP三次握手   所谓三次握手( ...

  8. sftp的安装和使用

    http://blog.srmklive.com/2013/04/24/how-to-setup-sftp-server-ftp-over-ssh-in-ubuntu/ In my previous ...

  9. 图解TCP/IP读书笔记(四)

    第四章.IP协议 IP(Internet Protocol,网际协议),作为整个TCP/IP中至关重要的协议,主要负责将数据包发送给最终的目标计算机.因此,IP能够让世界上任何两台计算机之间进行通信. ...

  10. Android笔记——Handler更新UI示例

    public class MainActivity extends ActionBarActivity { private TextView textView; private int i=0; @O ...