ACM学习历程—Rotate(HDU 2014 Anshan网赛)(几何)
Problem Description
Noting is more interesting than rotation!
Your
little sister likes to rotate things. To put it easier to analyze, your
sister makes n rotations. In the i-th time, she makes everything in the
plane rotate counter-clockwisely around a point ai by a radian of pi.
Now
she promises that the total effect of her rotations is a single
rotation around a point A by radian P (this means the sum of pi is not a
multiplier of 2π).
Of course, you should be able to figure out what is A and P :).
Input
The first line contains an integer T, denoting the number of the test cases.
For
each test case, the first line contains an integer n denoting the
number of the rotations. Then n lines follows, each containing 3 real
numbers x, y and p, which means rotating around point (x, y)
counter-clockwisely by a radian of p.
We promise that the sum of all p's is differed at least 0.1 from the nearest multiplier of 2π.
T<=100. 1<=n<=10. 0<=x, y<=100. 0<=p<=2π.
Output
For
each test case, print 3 real numbers x, y, p, indicating that the
overall rotation is around (x, y) counter-clockwisely by a radian of p.
Note that you should print p where 0<=p<2π.
Your answer will be considered correct if and only if for x, y and p, the absolute error is no larger than 1e-5.
Sample Input
1
3
0 0 1
1 1 1
2 2 1
Sample Output
1.8088715944 0.1911284056 3.0000000000
如
图,如果整个屏幕按照A点逆时针旋转a度,就会如图虚线的坐标。根据旋转,可以得到任意一个点旋转后的坐标。还有一点就是旋转最后的综合角度就是直接旋转
角度之和。然后最后得到的O'点,可以通过综合角度a,算出综合旋转中心A。这个旋转中心可以通过先将O‘沿OO’方向移位,使得,OA=OO‘,然后将
O’按照O逆时针旋转到A,求得,旋转角度是pi/2-a/2。
代码:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <string>
#define inf 0x3fffffff
#define esp 1e-10
using namespace std;
void Rotate(double &x0, double &y0, double x, double y, double a)
{
double xx, yy;
xx = x0*cos(a) - y0*sin(a) + x*( - cos(a)) + y*sin(a);
yy = x0*sin(a) + y0*cos(a) + y*( - cos(a)) - x*sin(a);
x0 = xx;
y0 = yy;
}
int main()
{
//freopen ("test.txt", "r", stdin);
int T;
scanf ("%d", &T);
for (int times = ; times < T; ++times)
{
double x0 = , y0 = , x, y, a, p = , ans, pi = 3.14159265358979323846;
int n;
scanf ("%d", &n);
for (int i = ; i < n; ++i)
{
scanf ("%lf%lf%lf", &x, &y, &a);
p += a;
Rotate(x0, y0, x, y, a);
}
while (p > *pi)
{
p -= *pi;
}
ans = p;
double k = /sin(p/2.0)/2.0;
x0 = x0 * k;
y0 = y0 * k;
p = pi/2.0 - p/2.0;
Rotate(x0, y0, , , p);
printf ("%f %f %f\n", x0, y0, ans);
}
return ;
}
ACM学习历程—Rotate(HDU 2014 Anshan网赛)(几何)的更多相关文章
- ACM学习历程—广东工业大学2016校赛决赛-网络赛F 我是好人4(数论)
题目链接:http://gdutcode.sinaapp.com/problem.php?cid=1031&pid=5 这个题目一看就是一道数论题,应该考虑使用容斥原理,这里对lcm进行容斥. ...
- ACM学习历程—广东工业大学2016校赛决赛-网络赛E 积木积水(最值问题 || 动态规划)
题目链接:http://gdutcode.sinaapp.com/problem.php?cid=1031&pid=4 这个题目自然会考虑到去讨论最长或者最短的板子. 笔上大概模拟一下的话,就 ...
- ACM学习历程—广东工业大学2016校赛决赛-网络赛D 二叉树的中序遍历(数据结构)
题目链接:http://gdutcode.sinaapp.com/problem.php?cid=1031&pid=3 这算是一个胡搞类型的题目.当然肯定是有其数据结构支撑的. 唯一的限制就是 ...
- ACM学习历程—广东工业大学2016校赛决赛-网络赛C wintermelon的魔界寻路之旅(最短路 && 递推)
题目链接:http://gdutcode.sinaapp.com/problem.php?cid=1031&pid=2 题目由于要找对称的路径,那么狠明显可以把右下角的每一块加到左上角对应的每 ...
- ACM学习历程—Hihocoder编程之美测试赛B题 大神与三位小伙伴(组合数学 )
时间限制:2000ms 单点时限:1000ms 内存限制:256MB 描述 给你一个m x n (1 <= m, n <= 100)的矩阵A (0<=aij<=10000),要 ...
- ACM学习历程——HDU 5014 Number Sequence (贪心)(2014西安网赛)
Description There is a special number sequence which has n+1 integers. For each number in sequence, ...
- ACM学习历程—HDU 5459 Jesus Is Here(递推)(2015沈阳网赛1010题)
Sample Input 9 5 6 7 8 113 1205 199312 199401 201314 Sample Output Case #1: 5 Case #2: 16 Case #3: 8 ...
- ACM学习历程—HDU 5451 Best Solver(Fibonacci数列 && 快速幂)(2015沈阳网赛1002题)
Problem Description The so-called best problem solver can easily solve this problem, with his/her ch ...
- ACM学习历程—HDU 5443 The Water Problem(RMQ)(2015长春网赛1007题)
Problem Description In Land waterless, water is a very limited resource. People always fight for the ...
随机推荐
- ProjectManager Beta 7 项目管理器发布
上次在Alpha阶段有一个可用版本Alpha 8也在这个博客发布了,传送:http://www.cnblogs.com/deali/p/ProjectManager.html ProjectManag ...
- IOS超强表格控件GMGridView
本文转载至 http://zyc-to.blog.163.com/blog/static/1715240020124235837247/ 介绍: iOS为我们提供UITableView类,实现了项目的 ...
- 快捷标签和ajax、json返回数据
<if 判断条件>标签</if><import>标签可以链接外部的样式表,和js<import file="js.util.Array" ...
- 【BZOJ3791】作业 DP
[BZOJ3791]作业 Description 众所周知,白神是具有神奇的能力的.比如说,他对数学作业说一声“数”,数学作业就会出于畏惧而自己完成:对语文作业说一声“语”,语文作业就会出于畏惧而自己 ...
- Collective Mindsets (easy)(逻辑题)
Collective Mindsets (easy) Time Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d &am ...
- A visual proof that neural nets can compute any function
http://neuralnetworksanddeeplearning.com/chap4.html In essence, we're using our single-layer neural ...
- IoC与DI
IoC与DI 首先想说说IoC(Inversion of Control,控制倒转).这是spring的核心,贯穿始终.所谓IoC,对于spring框架来说,就是由spring来负责控制对象的生命周期 ...
- 找出旋转有序数列的中间值python实现
题目给出一个有序数列随机旋转之后的数列,如原有序数列为:[0,1,2,4,5,6,7] ,旋转之后为[4,5,6,7,0,1,2].假定数列中无重复元素,且数列长度为奇数.求出旋转数列的中间值.如数列 ...
- eclipse---个人设置
window---- preferences -----修改背景颜色 -----修改字体 ----修改窗口主题 ----设置编码 -----设置编译环境 ----设置web项目JDK编译的版本 --- ...
- Python 不可变对象
str是不变对象,而list是可变对象. 对于可变对象,比如list,对list进行操作,list内部的内容是会变化的,比如: >>> a = ['c', 'b', 'a'] > ...