SDUT 2603:Rescue The Princess
Rescue The Princess
Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^
题目描述
Several days ago, a beast caught a beautiful princess and the princess was
 put in prison. To rescue the princess, a prince who wanted to marry the princess set out immediately. Yet, the beast set a maze. Only if the prince find out the maze’s exit can he save the princess.
Now, here comes the problem. The maze is a dimensional plane. The beast is
 smart, and he hidden the princess snugly. He marked two coordinates of an equilateral triangle in
 the maze. The two marked coordinates are A(x1,y1) and B(x2,y2). The third coordinate
 C(x3,y3) is the maze’s exit. If the prince can find out the exit, he can save the princess. After the prince comes into the maze, he finds out the A(x1,y1)
 and B(x2,y2), but he doesn’t know where the C(x3,y3) is. The prince need your help.
 Can you calculate the C(x3,y3)
 and tell him?
输入
The first line is an integer T(1 <= T <= 100) which is the number of test
 cases. T test cases follow. Each test case contains two coordinates A(x1,y1) and B(x2,y2),
 described by four floating-point numbers x1, y1, x2, y2 ( |x1|,
 |y1|, |x2|, |y2| <= 1000.0).
    Please notice that A(x1,y1)
 and B(x2,y2) and C(x3,y3) are in an anticlockwise direction from the equilateral triangle.
 And coordinates A(x1,y1) and B(x2,y2) are given by anticlockwise.
输出
output the coordinate of C(x3,y3), the result should be rounded to 2 decimal places in a line.
示例输入
4
-100.00 0.00 0.00 0.00
0.00 0.00 0.00 100.00
0.00 0.00 100.00 100.00
1.00 0.00 1.866 0.50
示例输出
(-50.00,86.60)
(-86.60,50.00)
(-36.60,136.60)
(1.00,1.00)
提示
来源
#include<stdio.h>
#include<math.h>
#define PI acos(-1.0)
int main()
{
int n;
scanf("%d",&n);
while(n--)
{
double x1,x2,y1,y2;
scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2);
double t=atan2(y2-y1,x2-x1)+PI/3.0;
double zz=sqrt(pow(x1-x2,2)+pow(y1-y2,2));
double x=zz*cos(t)+x1,y=zz*sin(t)+y1;
printf("(%.2lf,%.2lf)\n",x,y);
}
return 0;
}
SDUT 2603:Rescue The Princess的更多相关文章
- sdut 2603:Rescue The Princess(第四届山东省省赛原题,计算几何,向量旋转 + 向量交点)
		
Rescue The Princess Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 Several days ago, a b ...
 - sdutoj 2603 Rescue The Princess
		
http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2603 Rescue The Princess ...
 - 山东省第四届acm.Rescue The Princess(数学推导)
		
Rescue The Princess Time Limit: 1 Sec Memory Limit: 128 MB Submit: 412 Solved: 168 [Submit][Status ...
 - 计算几何 2013年山东省赛 A Rescue The Princess
		
题目传送门 /* 已知一向量为(x , y) 则将它旋转θ后的坐标为(x*cosθ- y * sinθ , y*cosθ + x * sinθ) 应用到本题,x变为(xb - xa), y变为(yb ...
 - 2013山东省“浪潮杯”省赛 A.Rescue The Princess
		
A.Rescue The PrincessDescription Several days ago, a beast caught a beautiful princess and the princ ...
 - 山东省赛A题:Rescue The Princess
		
http://acm.sdibt.edu.cn/JudgeOnline/problem.php?id=3230 Description Several days ago, a beast caught ...
 - H - Rescue the Princess ZOJ - 4097 (tarjan缩点+倍增lca)
		
题目链接: H - Rescue the Princess ZOJ - 4097 学习链接: zoj4097 Rescue the Princess无向图缩点有重边+lca - lhc..._博客园 ...
 - 山东省第四届ACM程序设计竞赛A题:Rescue The Princess
		
Description Several days ago, a beast caught a beautiful princess and the princess was put in prison ...
 - Rescue The Princess
		
Description Several days ago, a beast caught a beautiful princess and the princess was put in prison ...
 
随机推荐
- 数据库调优过程(二):找到IO不存在问题,而是sqlserver单表写入IO瓶颈
			
物理机上测试IO是否为瓶颈: 使用一个死循环insert into测试数据库最大写入速度: use [iTest]; declare @index int; ; begin ; INSERT into ...
 - ImportError: No module named setuptools
			
Python第三方模块中一般会自带setup.py文件,在Windows环境下,我们只需要使用命令 cd c:\Temp\foo python setup.py install 两个命令就可以完成第三 ...
 - codevs 1203 判断浮点数是否相等
			
http://codevs.cn/problem/1203/ 1203 判断浮点数是否相等 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 青铜 Bronze 题解 查看运行 ...
 - [转]JVM内幕:Java虚拟机详解
			
本文由 ImportNew - 挖坑的张师傅 翻译自 jamesdbloom.欢迎加入翻译小组.转载请见文末要求. 这篇文章解释了Java 虚拟机(JVM)的内部架构.下图显示了遵守Java SE 7 ...
 - Java基础(8):方法重载的4个依据与例子
			
判断方法重载的依据: 1. 必须是在同一个类中 2. 方法名相同 3. 方法参数的个数.顺序或类型不同 4. 与方法的修饰符或返回值没有关系 运行结果:
 - centos每天一句命令
			
shutdown -h now 立刻关机 后面可以加上关键的时间 -r 重启 reboot 重启 同时记载以下,仅仅给刚刚接触的新手来说的 按两次tab 键会自动命令 cd 到目录下 su r ...
 - 同时启动多个Tomcat
			
一,修改配置文件server.xml的端口 C:\apache-tomcat-5.5.23-1\conf\server.xml用记事本什么的打开修改3个地方 第一: <Server port ...
 - JAVA中extends 与implements区别
			
JAVA中extends 与implements有啥区别?1. 在类的声明中,通过关键字extends来创建一个类的子类.一个类通过关键字implements声明自己使用一个或者多个接口.extend ...
 - Java中this关键字的使用
			
本文介绍了在Java中this关键字的作用于使用方法 当局部变量和成员变量重名时,在方法中使用this时,表示的是该方法所在类中的成员变量.(this指的是当前对象自己) 如:public class ...
 - VisualSVNServer启动失败错误处理
			
VisualSVNServerServer service failed to start: 服务已返回特定的服务器错误代码:(0x8007042a) Please check Vis ...