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 ...
随机推荐
- 运行sql server profiler所需的权限
********运行Sql Server Profiler所需的权限(performance)*********/ --EG. -- 使用TRACE帐户(Performancetest)跟踪Sql S ...
- Tomcat类加载器机制
Tomcat为什么需要定制自己的ClassLoader: 1.定制特定的规则:隔离webapp,安全考虑,reload热插拔 2.缓存类 3.事先加载 要说Tomcat的Classloader机制,我 ...
- 学习jsp(3)
HttpServletRequest和HttpServletResponse: response.setContentType("text/html;charset=UTF-8") ...
- 转:Python获取随机数(中文)
下面介绍下random中常见的函数. 前提:需要导入random模块 >>>import random 1.random.random random.random() 用于生成一个0 ...
- ACM/ICPC竞赛
ACM知识点分类 第一类:基础算法 (1) 基础算法:枚举,贪心,递归,分治,递推,构造,模拟 (2) 动态规划:背包问题,树形dp,状态压缩dp,单调性优化,插头dp (3) 搜索:dfs,bf ...
- java项目中可能会使用到的jar包解释
一.Struts2 用的版本是struts2.3.1.1 一个简单的Struts项目所需的jar包有如下8个 1. struts2-core-2.3.1.1.jar: Struts2的核心类库. 2. ...
- cocos2d-x游戏开发之动画
MyGame.h中声明动画函数: class MyGame : public cocos2d::Layer{public: static Scene* createScene(); void U ...
- /Users/alamps/AndroidStudioProjects/Demo11ListView
package com.example.demo11listview; import android.os.Bundle; import android.app.Activity; import an ...
- 解决无法连接到visual studio开发服务器的问题
今天vs抽风,调试网站出现下图那样: 然后我开始百度搜索 "无法连接到visual studio开发服务器" 出现很多文章: 打开一篇问题,看了里面的内容, 那个解决办法也不是最好 ...
- Uploadify在MVC中使用方法案例(上传单张图片)
在View视图中: <link href="/Scripts/uploadify-v3.2.1/uploadify.css" rel="stylesheet&quo ...