UVA - 10250 - The Other Two Trees (简单计算几何)_zzuspy的博客-程序员宅基地

技术标签: UVA  iostream  计算几何  acm  icpc  ~~~~~~~~~~计算几何  

UVA - 10250

Time Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld & %llu

Submit Status

Description

Download as PDF

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)

Source

Root :: Prominent Problemsetters ::  Shahriar Manzoor

Root :: AOAPC I: Beginning Algorithm Contests (Rujia Liu) :: Volume 1. Elementary Problem Solving ::  Maths - Simple Geometry
Root :: Competitive Programming 3: The New Lower Bound of Programming Contests (Steven & Felix Halim) :: (Computational) Geometry :: Basic Geometry :: Points and Lines


题意: 就是给你正方形两个对顶顶点的坐标,求另外两个顶点的坐标


AC代码:



#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;

int main()
{
	double x1, y1, x2, y2;
	while(scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2)!=EOF)
	{
		if(fabs(x1-x2)<1e-7 && fabs(y1-y2)<1e-7)
		{
			printf("Impossible.\n");
			continue;
		}
		double midx, midy, x3, y3, x4, y4, t1, t2, k;
		midx = (x1 + x2) / 2; midy = (y1 + y2) / 2;
		t1 = (x1 - midx)*(x1 - midx) + (y1 - midy)*(y1 - midy);
		k = (y1-y2)/(x1-x2);   //对定点组成直线的斜率 
		t2 = t1 / (k*k + 1);    
		x3 = midx - k*sqrt(t2); x4 = midx + k*sqrt(t2);
		y3 = midy + sqrt(t2); y4 = midy - sqrt(t2);
		printf("%.10lf %.10lf %.10lf %.10lf\n", x3, y3, x4, y4);
	} 
	return 0;
} 





版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/u014355480/article/details/41849325

智能推荐

oracle 查看 pdb名称,oralce 12c 表空间查询(包含pdb)_weixin_39915694的博客-程序员宅基地

SELECT DB_NAME,con_id,RES_NAME,TABLE_SIZE,USED_SIZE,USE_PERCENT,AVA_SIZE,AUTOEXTENSIBLE,CONTENTSFROM (SELECT tt.con_id,nvl(x.name, 'CDB$ROOT') AS DB_NAME,ts1.tablespace_name AS "RES_NAME",round(nvl(tt...

RFC3261(2 SIP协议功能概述)_weixin_30820077的博客-程序员宅基地

SIP是一个应用层的控制协议,可以用来建立、修改、和终止多媒体会话(或者会议),例如Internet电话。SIP可以邀请参与者加入已经存在的会话,比如多方会议。媒体可以在一个已经存在的会话中方便的增加(或者删除)。SIP显示的支持名字映射和重定向服务,这个用于支持个人移动业务-用户可以使用一个形式上容易理解的标志来替代他们的网络地址。SIP在建立和终止多媒体通信上,支持5个方面的应用:用...

Spring学习心得(18)-- 通知的种类_琴剑山庄的博客-程序员宅基地

通知的种类:1、前置通知2、后置通知3、最终通知4、异常通知5、环绕通知在之前的例子中,我们使用到了before(前置通知)和after-returning(后置通知)。还有after最终通知(最终通知)和around(环绕通知)。前置通知和后置通知已经在前面的帖子涉及到,这里只做总结:前置通知:*在目标方法执行前执行*所以目标方法如果出现异常,

【JAVA】记一次典型jvm内存泄漏_xbl丶的博客-程序员宅基地

一、问题概述在持续十分钟的压力测试中,单机QPS从8000陆续降低至3000的过程中发现的内存泄漏。先看一下压测计算的数据:首先是被压测的机器:机器配置:4核8G 单机预计QPS:8000左右,不超过9000 平均响应时间:12~13ms发起压测的执行机:设置单机并发数:60 执行机数量:2台由此可以计算出进行压测的QPS数据:平均响应时间为12ms,单机60的并发数,则单机的最高QPS为 60/0.012 = 5000 左右设置持续上涨4分钟,达到峰值,则可得出:

Windows Practice_闹钟(四)_GDI对象概述_艺术人生666的博客-程序员宅基地

GDI对象概述在使用GDI绘制的时候,我们需要注意两套坐标体系,一个是对于当前界面程序的原点坐标,一个是对于桌面(系统)的原点坐标。 所以以后在看到和DC相关的函数时,它都代表和DC有关的坐标,比如TExtOut函数,它的就是和DC相关的函数。 TextOut在指定位置输出指定长度的字符串。函数原型如下:BOOL TextOut( _In_ HDC hdc, _In_ int

随便推点

win7使用USB转串口连接mini2440方法_weixin_34192732的博客-程序员宅基地

不想嚼别人吃剩的馍。我只说我自己是怎么痛苦的连上的。环境设备:  window7笔记本,没有串口,装有XP和Ubuntu2个虚拟机(不是必须的,我只是说明一下我的环境)  友善之臂mini2440(含USB转串口设备一个,串口线一条)尝试过程(官方手册完全是废):手册是的环境是xp,自带“超级终端”。于是我自己百度下载超级终端,搞了不成。我想可能是win7不好用...

html可收缩展开的表单,【HTML】可以收缩和和伸展的表格_Muses Station的博客-程序员宅基地

www.webjx.com function tablecollapse() { /* Variables */ var collapseClass='footcollapse'; var collapsePic='http://webdesign.bitscn.com/UploadFiles_8014/200706/20070620173213376.gif'; va...

浙江计算机c语言上机怎么写,浙江省计算机二级c语言上机考试真题(三)程序编写..._就大概是这样的博客-程序员宅基地

浙江省计算机二级c语言上机考试真题(三)程序编写 (21页) 本资源提供全文预览,点击全文预览即可全文预览,如果喜欢文档就下载吧,查找使用更方便哦!24.9 积分(三)程序编写1,求3元方程解设计程序统计满足条件XXYYZZ2000的所有解的个数,并将统计结果以格式“D“输出。说明若A、B、C是1个解,则A、C、B也是1个解,等等。/INCLUDE“STDIOH“INTMAIN{INTX,Y,Z...

mobiscroll 控件的使用(手机端日历控件)_weixin_30650039的博客-程序员宅基地

先上一张图吧:控件的下载地址:http://www.kuitao8.com/20140604/2615.shtml文档API地址:http://docs.mobiscroll.com/2-13-2/datetime#!opt-minDate网卡案例:http://www.wglong.com/main/artical!details?id=11现在直接贴代码了,js引用部分...

TortoiseSVN2IDE.pas源代码_weixin_30408309的博客-程序员宅基地

unit TortoiseSVN2IDE;{$R 'icons.res'}interfaceuses ToolsAPI, SysUtils, Windows, Dialogs, Menus, Registry, ShellApi, Classes, Controls, Graphics, ImgList, ExtCtrls, ActnList,Forms;//增加了对Forms单...

String和Date转换_weixin_30628801的博客-程序员宅基地

1.Date转String Date date = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String dateTime = sdf.format(date);2.String 转Date ...

推荐文章

热门文章

相关标签