2013山东省“浪潮杯”省赛 A.Rescue The Princess
A.Rescue The PrincessDescription
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.
Input
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).
Output
For each test case, you should output the coordinate of C(x3,y3), the result should be rounded to 2 decimal places in a line.
Sample Input
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
Sample Output
(-50.00,86.60)
(-86.60,50.00)
(-36.60,136.60)
(1.00,1.00)
最原始方法是算算算,在别人博客学到的是用旋转矩阵的,感觉厉害多了..
例如:把向量写成坐标形式并视为一个2*1列向量,再左乘一个2*2的矩阵,这样得到的新的2*1列向量就是旋转后的向量的坐标。(2*2矩阵结构如下:设旋转 角度为a, 那么左上角和右下角的元素为cos(a), 右上角的元素为-sin(a), 左下角的元素为sin(a))。
#include<cstdio>
#include<cstring>
#include<cmath>
const double sq3=sqrt(3.0);
double m1[][],m3[][];
double m2[][]= {{0.5,sq3/},{-sq3/,0.5}};
void so()
{
memset(m3,,sizeof(m3));
for(int k=; k<; ++k)
for(int j=; j<=; ++j)
{
//printf("m1[0][%d]=%lf m2[%d][%d]=%lf\n",k,m1[0][k],k,j,m2[k][j]);
m3[][j]+=m1[][k]*m2[k][j];
} }
int main()
{
int T;
scanf("%d",&T);
while(T--)
{
double x1,x2,y1,y2;
scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2);
m1[][]=x2-x1;
m1[][]=y2-y1;
so();
printf("(%.2lf,%.2lf)\n",m3[][]+x1,m3[][]+y1);
}
return ;
}
2013山东省“浪潮杯”省赛 A.Rescue The Princess的更多相关文章
- [ACM]2013山东省“浪潮杯”省赛 解题报告
题目地址:http://acm.upc.edu.cn/problemset.php?page=13 2217~2226 A.Rescue The Princess 一个等边三角形告诉前2个点,求逆时 ...
- 计算几何 2013年山东省赛 A Rescue The Princess
题目传送门 /* 已知一向量为(x , y) 则将它旋转θ后的坐标为(x*cosθ- y * sinθ , y*cosθ + x * sinθ) 应用到本题,x变为(xb - xa), y变为(yb ...
- 2014山东省“浪潮杯”第五届ACM省赛总结
一次比赛做一次总结,弱菜又来总结了…… 我这种大四的又死皮赖来混省赛了,貌似就我和山大威海的某哥们(不详其大名)了吧.颁奖前和他聊天,得知他去百度了,真是不错,ORZ之. 比赛流水账: 题目目前不知道 ...
- Anagram(山东省2018年ACM浪潮杯省赛)
Problem Description Orz has two strings of the same length: A and B. Now she wants to transform A in ...
- 2013年蓝桥杯省赛C/C++A组真题解析
1.高斯日记 大数学家高斯有个好习惯:无论如何都要记日记. 他的日记有个与众不同的地方,他从不注明年月日,而是用一个整数代替,比如:4210 后来人们知道,那个整数就是日期,它表示那一天是高斯出生后的 ...
- sdut 2603:Rescue The Princess(第四届山东省省赛原题,计算几何,向量旋转 + 向量交点)
Rescue The Princess Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 Several days ago, a b ...
- 山东省赛A题:Rescue The Princess
http://acm.sdibt.edu.cn/JudgeOnline/problem.php?id=3230 Description Several days ago, a beast caught ...
- Sdut 2409 The Best Seat in ACM Contest(山东省第三届ACM省赛 H 题)(模拟)
题目描述 Cainiao is a university student who loves ACM contest very much. It is a festival for him once ...
- [原]sdut2624 Contest Print Server (大水+大坑)山东省第四届ACM省赛
本文出自:http://blog.csdn.net/svitter 原题:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&am ...
随机推荐
- C# : 操作Word文件的API - (将C# source中的xml注释转换成word文档)
这篇博客将要讨论的是关于: 如何从C#的source以及注释, 生成一份Word格式的关于各个类,函数以及成员变量的说明文档. 他的大背景如下...... 最近的一个项目使用C#, 分N个模块, 在项 ...
- SON-RPC for Java
JSON-RPC for Java https://github.com/briandilley/jsonrpc4j#json-rpc-for-java This project aims to pr ...
- GMM-HMM语音识别模型 原理篇
本文简明讲述GMM-HMM在语音识别上的原理,建模和測试过程.这篇blog仅仅回答三个问题: 1. 什么是Hidden Markov Model? HMM要解决的三个问题: 1) Likelihood ...
- Asp.Net MVC 3【Filters(过滤器)】
这里分享MVC里的Filters(过滤器),什么是MVC里的过滤器,他的作用是什么? 过滤器的请求处理管道中注入额外的逻辑.他们提供了一个简单而优雅的方式来实现横切关注点.这个术语是指所有对应用程序的 ...
- android151 笔记 3
34. 对android虚拟机的理解,包括内存管理机制垃圾回收机制. 虚拟机很小,空间很小,谈谈移动设备的虚拟机的大小限制 16M , 谈谈加载图片的时候怎么处理大图片的,压缩. 垃圾回收,没有引用的 ...
- Java多线程中start()和run()的区别
Java的线程是通过java.lang.Thread类来实现的.VM启动时会有一个由主方法所定义的线程.可以通过创建Thread的实例来创建新的线程.每个线程都是通过某个特定Thread对象所对应的方 ...
- 图形化管理debian服务
bootupmanager这个软件 ,用着勉强吧, 功能不多. 安装 sudo apt-get install bum 卸载sudo apt-get remove --purge bum 多了不说 , ...
- 使用hibernate自动创建Mysql表失败原因
1.使用 schemaExport(hibernate5.2.3)创建Mysql表 @Test public void testSchemaExport() { ServiceRegistry ser ...
- SQL Server 通配符 Wildcard character
SQL Server 通配符 Wildcard character % 任意长度的字符串,如:'%computer%' _ 单个字符,如:'_ean' [] ...
- [转]网站优化-IIS7下静态文件的优化
本文转自:http://www.cnblogs.com/Leung/archive/2009/10/26/1590256.html 在网站开发过程中,通常我们会对网站的静态文件做处事,像图片文件,CS ...