Rotate+hud+2014鞍山网络赛
来源:互联网 发布:改后台淘宝会查吗 编辑:程序博客网 时间:2024/04/28 16:22
Rotate
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 96 Accepted Submission(s): 48
Special Judge
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 :).
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π.
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.
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
130 0 11 1 12 2 1
Sample Output
1.8088715944 0.1911284056 3.0000000000解决方案:这题被坑了,就是高中数学没学好。当某点逆时针旋转过180度时,要注意如果求的是弦与半径组成的三角形的顶角,这是顺时针的旋转的角,要转成逆时针的角。code:#include <iostream>#include<cstdio>#include<cstring>#include<cmath>using namespace std;const double pi=3.14159265358979323846;double dist(double x1,double y1,double x2,double y2){ return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)+1e-8);}void rot(double x0,double y0,double p,double oldx,double oldy,double *newx,double *newy){ double d=dist(x0,y0,oldx,oldy); *newx=x0+(oldx-x0)*cos(p)-(oldy-y0)*sin(p); *newy=y0+(oldy-y0)*cos(p)+(oldx-x0)*sin(p);}int main(){ int t; scanf("%d",&t); while(t--) { int n; scanf("%d",&n); double x0,y0,p,px=0.0; bool flag=false; double prex=-1.0,prey=-1.0; double oldx1=110.0,oldy1=110.0,oldx2=120.0,oldy2=120.0; double newx1=110.0,newy1=110.0,newx2=120.0,newy2=120.0; for(int i=0; i<n; i++) { scanf("%lf%lf%lf",&x0,&y0,&p); if(prex<0&&prey<0) { prex=x0,prey=y0; } else { if(fabs(prex-x0)>=1e-8||fabs(prey-y0)>=1e-8) { flag=true; } } px+=p; if(px-2*pi>1e-8) px-=2*pi; rot(x0,y0,p,oldx1,oldy1,&newx1,&newy1); oldx1=newx1,oldy1=newy1; rot(x0,y0,p,oldx2,oldy2,&newx2,&newy2); oldx2=newx2,oldy2=newy2; } if(n==1||!flag) { printf("%.10lf %.10lf %.10lf\n",x0,y0,px); continue; } double a=(oldx1*oldx1+oldy1*oldy1-110*110-110*110)/(110-oldy1); double b=(-oldx2*oldx2-oldy2*oldy2+120*120+120*120)/(120-oldy2); double c=2*((oldx1-110)/(-oldy1+110)-(oldx2-120)/(-oldy2+120)); double x=(a+b)/c; double a1=(oldx1*oldx1+oldy1*oldy1-110*110-110*110)/(-110+oldx1); double b1=(oldx2*oldx2+oldy2*oldy2-120*120-120*120)/(-120+oldx2); double c1=2*((oldy1-110)/(oldx1-110)-(oldy2-120)/(oldx2-120)); double y=(a1-b1)/c1; double d1=dist(oldx1,oldy1,110,110)/2.0; double d2=dist(oldx1,oldy1,x,y); double p1=2*asin(d1/d2); double xx; double yy; rot(x,y,p1,110,110,&xx,&yy);///判断求出的角度是否为顺时针所转的角 if(fabs(xx-oldx1)<=1e-8&&fabs(yy-oldy1)<=1e-8){ printf("%.10lf %.10lf %.10lf\n",x,y,p1); } else{ p1=2*pi-p1; printf("%.10lf %.10lf %.10lf\n",x,y,p1); } //if(oldx1) } return 0;}
0 0
- Rotate+hud+2014鞍山网络赛
- HDU 4998 Rotate(计算几何)2014年鞍山赛区网络赛
- HDU 4998 Rotate (2014年鞍山赛区网络赛B题)
- HDU 4998 Rotate(鞍山网络赛B题)
- 2014网络赛 鞍山赛区
- 2014 鞍山网络赛 hdu 5003 Osu!
- HDU_5053_2014年鞍山网络赛
- HDU-5001 Walk 2014年鞍山网络赛E题
- 2014鞍山网络赛 E题||hdu 5001 概率dp
- HDU -- 5001 Walk(2014鞍山网络赛E)(概率)
- hdu5001 鞍山赛区网络赛 E题
- acm_icpc网络赛第二站:鞍山赛区
- hdu5000 Clone 鞍山网络赛D题
- 2014ACM-ICPC赛区鞍山网络预赛
- hdu 5001 Walk 2014鞍山网络赛E 矩阵快速幂
- LCT link-cut tree Hdu 5002 Tree 2014鞍山网络赛
- HDU 5003 Osu! (2014年鞍山赛区网络赛G题)
- HDU 5000 Clone (2014年鞍山赛区网络赛D题)
- 关于Java多线程和并发运行的学习(四)——之Semaphore
- 到底谁在使用爬虫,使用蜘蛛?
- Oracle 启动过程
- HDU46道DP题[转自网络]
- 中缀表达式求值问题
- Rotate+hud+2014鞍山网络赛
- Oracle的存储结构关系
- oracle 更改字符编码集
- Unix系统文件类型和访问权限
- 的感情和合格的放弃过回复
- magento 判断是否为可配置产品
- 《大话数据结构》读书笔记之线性表抽象数据类型(双向循环链表实现)
- 蜘蛛抓取文件标准写法
- 大三女生在面对各种语言面前有些迷茫