HDU4998 Rotate (2014 ACM/ICPC Asia Regional Anshan Online)
題目連結:http://acm.hdu.edu.cn/showproblem.php?pid=4998
題意:給定n個點 和n個角度 ,平面內一個點分別以這個點Point(i)為旋轉中心 逆時針旋轉 R(i)度
求最後相當於繞那個點旋轉多少度 求這個點的座標 以及旋轉的角度
一點(x,y)繞一個點(x0,y0)旋轉 r0 度的公式為
x1= (x - x0)*cos(r0) - (y - y0)*sin(r0) + x0 ;
y1= (x - x0)*sin(r0) + (y - y0)*cos(r0) + y0 ;
最後旋轉點肯定是最後這兩條由(xs1,ys1) (xs2,xs2) 組成的直線 以及 由(xe1,ye1) (xe2,xe2) 垂直平分線的交點,ansr = (r1+r2+.....+rn)%(2*pi);
程式碼如下:
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
const double pi = acos(-1.0);
struct point{
double x,y;
};
point calu(point a,point b,double r)
{
point c;
c.x = (a.x - b.x) * cos(r) - (a.y - b.y) * sin(r) + b.x;
c.y = (a.x - b.x) * sin(r) + (a.y - b.y) * cos(r) + b.y;
return c;
}
int main()
{
int n,t;
scanf("%d",&t);
while(t--){
point a,b,c,d;
double r,ansr;
scanf("%d",&n);
a.x=a.y=0;
b.x=b.y=1;
ansr=0;
for(int i=0;i<n;i++){
scanf("%lf%lf%lf",&c.x,&c.y,&r);
ansr+=r;
if(ansr>=2*pi)
ansr-=2*pi;
a=calu(a,c,r);
b=calu(b,c,r);
}
double t1 = (a.x*a.x+a.y*a.y)*(2*b.y-2)-2*a.y*(b.x*b.x+b.y*b.y)+4*a.y;
double t2 = 4*a.y-4*a.y*b.x+4*a.x*b.y-4*a.x;
double x = t1/t2;
double t3 = (a.x*a.x+a.y*a.y)-2*x*a.x;
double t4 = 2*a.y;
double y = t3/t4;
printf("%lf %lf %lf\n",x,y,ansr);
}
return 0;
}
相關文章
- 2017 ACM/ICPC Asia Regional Shenyang Online - 做題記錄ACM
- 2013 ACM/ICPC Asia Regional Online —— Warmup2 兩個水題ACM
- HDU5023A Corrupt Mayor's Performance Art (2014 ACM/ICPC Asia Regional Guangzhou Online)ORMACM
- 2015 ACM/ICPC Asia Regional Shenyang Online-1012 Largest PointACM
- HDU 5052 Yaoge’s maximum profit 光禿禿的樹鏈拆分 2014 ACM/ICPC Asia Regional Shanghai Online...ACMAI
- The 2021 ICPC Asia Shenyang Regional Contest
- 2016-2017 ACM-ICPC Asia-Bangkok Regional ContestACM
- 2018-2019 ACM-ICPC, Asia Seoul Regional Contest——A - CircuitsACMUI
- The 2024 ICPC Asia Nanjing Regional ContestNaN
- The 2022 ICPC Asia Nanjing Regional ContestNaN
- The 2023 ICPC Asia Macau Regional ContestMac
- The 2022 ICPC Asia Xian Regional Contest
- The 2022 ICPC Asia Hangzhou Regional Programming Contest
- The 2022 ICPC Asia Xian Regional Contest 前六題
- The 2023 ICPC Asia EC Regionals Online Contest (I)
- The 2024 ICPC Asia East Continent Online Contest (I)AST
- The 2022 ICPC Asia Nanjing Regional Contest IGDA,和令人疑惑的MNaN
- The 2023 ICPC Asia Hangzhou Regional Contest (The 2nd Universal Cup. Stage 22: Hangzhou)
- 2017-2018 ACM-ICPC Southeast Regional Contest (Div. 1)ACMAST
- 2017-2018 ACM-ICPC Pacific Northwest Regional Contest (Div. 1)ACM
- 2017-2018 ACM-ICPC, Central Europe Regional Contest (CERC 17)ACM
- Chayas - 2023-2024 ICPC, Asia Yokohama Regional Contest 2023, Problem E
- The 2024 ICPC Asia EC Regionals Online Contest (II) - Problem B. Mountain BookingAI
- The 2024 ICPC Asia EC Regionals Online Contest (II) - Problem H. Points Selection
- 2017-2018 ACM-ICPC Southwestern European Regional Programming Contest (SWERC 2017)ACM
- The 2023 ICPC Asia Jinan Regional Contest (The 2nd Universal Cup. Stage 17: Jinan)補題記錄NaN
- 2016-2017 ACM-ICPC Northwestern European Regional Programming Contest (NWERC 2016)ACM
- 2016-2017 ACM-ICPC Southwestern European Regional Programming Contest (SWERC 2016)ACM
- ACM ICPC Vietnam National Second RoundACM
- ACM/ICPC2014鞍山現場賽E hdu5074Hatsune MikuACM
- HDU4091(2011 Asia Shanghai Regional Contest)AI
- acm/icpc入門級演算法模板ACM演算法
- 2015 ACM/ICPC EC-FinalACM
- 2024 ICPC Online 第二場(K)
- HDU3714 Error Curves(2010 Asia Chengdu Regional Contest)Error
- 2014ACM/ICPC亞洲區西安站 F題 color (組合數學,容斥原理)ACM
- SDNU_ACM_ICPC_2021_Winter_Practice_4th [個人賽]ACM
- ACM創新實驗室代表隊成功闖入ICPC ACM青島區域賽現場賽ACM