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 ...
随机推荐
- bootstrap ace treeview树表
html部分 <div class="widget-main padding-8" style="height:400px;overflow-y: scroll;& ...
- lvs负载均衡的搭建
lvs负载均衡的搭建 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 在部署环境前,我们需要了解一下一些协议 一.什么是arp 地址解析协议,即ARP(Addr ...
- 转:Python获取随机数(中文)
下面介绍下random中常见的函数. 前提:需要导入random模块 >>>import random 1.random.random random.random() 用于生成一个0 ...
- how to use automapper in c#, from cf~
[DataContract] public class GroupDto { [DataMember] public int id { get; set; } [DataMember] public ...
- STL lower_bound upper_bound binary-search
STL中的二分查找——lower_bound .upper_bound .binary_search 二分查找很简单,原理就不说了.STL中关于二分查找的函数有三个lower_bound .upper ...
- jnlp jws
http://www.mkyong.com/java/java-web-start-jnlp-tutorial-unofficial-guide/
- 解决ScrollView与ListView事件冲突
1,在最近做项目的时候使用ScrollView嵌套ListView的时候发现ListView的滑动效果失效,简单的网上搜索了一下,也就有了下面的解决方法,在ListView中设置事件的监听listvi ...
- centOS6.6升级gcc4.8
最近想升级mesos0.23.0,结果编译mesos0.23.0需要gcc4.8+,可是centOS6.6最高版本的gcc也只到4.4.7版本,只好手动升级一下了. 下载4.8.2源码 wget ft ...
- paper 73 :HDR(High Dynamic Range Imaging)在摄影中指高动态范围成像
HDR(High Dynamic Range Imaging)在摄影中指高动态范围成像.国内的教程基本语焉不详,找到一篇比较详尽的国外教程翻译出来,希望对大家有帮助.^_^ 原文地址:http://p ...
- react tab
<!DOCTYPE html> <html> <head> <script src="js/react.js"></scrip ...