//线段树 延迟标签
//
#include <bits/stdc++.h>
using namespace std;
const int maxn=1e4+5;
double x[maxn*4];
double y[maxn*4];
int degreen[maxn];
int d[maxn*4];//延迟标签
void rotate(int i,int num)
{
double ang=(1.0*num)/180*acos(-1);
double newx=x[i]*cos(ang)-y[i]*sin(ang);//向量逆时针转动后的x坐标;
double newy=x[i]*sin(ang)+y[i]*cos(ang);
x[i]=newx;
y[i]=newy;
}
void pushdown(int i)
{
d[i<<1]+=d[i];
d[i<<1|1]+=d[i];
rotate(i<<1,d[i]);
rotate(i<<1|1,d[i]);
d[i]=0;
}
void pushup(int i)
{
x[i]=x[i<<1]+x[i<<1|1];
y[i]=y[i<<1]+y[i<<1|1];
}
void build(int l,int r,int root)
{
d[root]=0;
if(l==r)
{
x[root]=0;
scanf("%lf",&y[root]);
return;
}
int mid=(l+r)>>1;
build(l,mid,root<<1);
build(mid+1,r,root<<1|1);
pushup(root);
}
void update(int index,int l,int r,int root,int ang)
{
if(l>=index)
{
rotate(root,ang);
d[root]+=ang;
return;
}
int mid=l+r>>1;
pushdown(root);
if(index<=mid)
update(index,l,mid,root<<1,ang);
update(index,mid+1,r,root<<1|1,ang);
pushup(root);
}
int main()
{
int n,c;
scanf("%d%d",&n,&c);
build(1,n,1);
for(int i = 1;i <= n;++i)
degreen[i]=180;
for(int i = 1;i <= c;++i)
{
int a,b;
scanf("%d%d",&a,&b);
update(a+1,1,n,1,b-degreen[a]);
degreen[a]=b;
printf("%.2lf %.2lf\n",x[1],y[1]);
}
return 0;
}

Crane (POJ 2991)的更多相关文章

  1. AC日记——Crane poj 2991

    POJ - 2991 思路: 向量旋转: 代码: #include <cmath> #include <cstdio> #include <cstring> #in ...

  2. POJ 2991 Crane(线段树+计算几何)

    POJ 2991 Crane 题目链接 题意:给定一个垂直的挖掘机臂.有n段,如今每次操作能够旋转一个位置,把[s, s + 1]专程a度,每次旋转后要输出第n个位置的坐标 思路:线段树.把每一段当成 ...

  3. (中等) POJ 2991 Crane , 几何+线段树。

    Description ACM has bought a new crane (crane -- jeřáb) . The crane consists of n segments of variou ...

  4. POJ 2991 Crane(线段树)

    Crane Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 7687   Accepted: 2075   Special J ...

  5. POJ 2991 Crane (线段树)

    题目链接 Description ACM has bought a new crane (crane -- jeřáb) . The crane consists of n segments of v ...

  6. POJ - 2991 Crane (段树+计算几何)

    Description ACM has bought a new crane (crane -- jeřáb) . The crane consists of n segments of variou ...

  7. POJ 2991–Crane【线段树+几何】

    题意: 把手臂都各自看成一个向量,则机械手的位置正好是手臂向量之和.旋转某个关节,其实就是把关节到机械手之间的手臂向量统统旋转. 由于手臂很多,要每个向量做相同的旋转操作很费时间.这时就可以想到用线段 ...

  8. [poj 2991]Crane[线段树表示向量之和,而非数量]

    题意: 起重机的机械臂, 由n段组成, 对某一些连接点进行旋转, 询问每次操作后的末端坐标. 思路: 由于旋转会影响到该点之后所有线段的角度, 因此容易想到用线段树记录角度, 成段更新. (但是不是每 ...

  9. POJ 2991 Crane

    线段树+计算几何,区间更新,区间求和,向量旋转. /* *********************************************** Author :Zhou Zhentao Ema ...

随机推荐

  1. springMvc接收ajax数组参数,以及jquery复选框选中、反选、全选、全不选

    一.复选框选中.反选.全选.全不选 html代码: <input type='checkbox' name='menuCheckBox' value='10' >苹果 <input ...

  2. 根据导出的查询结果拼接字符串,生成sql语句并保存到txt文件中

    import os os.chdir("C:/") path = os.getcwd() print(path) f = open("sql.csv") # p ...

  3. Windows中的备份和还原

    1:增量备份 (查看文件属性,只备打了勾的,备完后把勾取消掉,修改后勾都会打上) 2:差异备份(备份有勾的 ,备份完后不会取消勾) 周一:备一 周二:备二 周三:备三 周四:备三,四

  4. windows2012 IIS部署GeoTrust证书踩过的坑。 视频测试可用 IIS 证书导入

    证书导入方式 https://wenku.baidu.com/view/3504f29a55270722192ef78a.html https://www.cnblogs.com/jackrebel/ ...

  5. 使用python函数持续监控电脑cpu使用率、内存、c盘使用率等

    方法一: # import time 导入time模块 # import psutil 导入psutil模块 # def func(): # while True: ------->持续监控得w ...

  6. 团队第四次 # scrum meeting

    github 本此会议项目由PM召开,召开时间为4-8日晚上10点 召开时长15分钟 任务表格 袁勤 负责编写登陆逻辑 https://github.com/buaa-2016/phyweb/issu ...

  7. Dao层抽取BaseDao公共方法

    设计IBseDao接口,定义公共的CRUD方法. // IBaseDao 接口,定义公共的CRUD方法 public interface IBaseDao<T> { public void ...

  8. mysql查看及设置最大连接数

    #查看: show variables like '%max_connections%'; #设置: set GLOBAL max_connections = 1000;

  9. Jquery如何序列化form表单数据为JSON对象

    jquery提供的serialize方法能够实现. $("#searchForm").serialize();但是,观察输出的信息,发现serialize()方法做的是将表单中的数 ...

  10. 微信小程序代码大全 - 小程序开发福利

    小程序QQ交流群:131894955 小程序开发文档(Wepy) 小程序商城源码下载(weixin-app-shop) 小程序官网源码下载(weixin-app-cms) 微信管家平台JAVA版开源下 ...