//线段树 延迟标签
//
#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. php如何和linux进行通讯

    FastCGI原理 FastCGI是一个运用于Http Server和动态脚本语言间通信的接口,多数流行的Http Server都支持FastCGI,包括Apache.Nginx和lighttpd等. ...

  2. mysql之工具的使用总结(mac版本)

    13.mysql Mac终端操作 12.MySql在Mac上的安装与配置详解: 11.mac下安装mysql5.7.18,连接出现Access denied for user 'root'@'loca ...

  3. 去中心化存储项目终极指南 | Filecoin, Storj 和 PPIO 项目技术对比(下)

    在上篇文章中,我们主要从价值定位.技术层次架构.服务质量.去中心化程度,和经济激励机制五个方面分析了三个项目的不同.在这一篇文章中,我们将着重从区块链的架构设计.数据传输技术设计和数据存储技术设计三方 ...

  4. 完成端口IOCP详解

    修改自: http://blog.csdn.net/piggyxp/article/details/6922277 ps: 原作者很厉害了, 把一个iocp模型讲解的这么形象,不过在实践过程中发现一些 ...

  5. systemverilog.vim

    " Vim syntax file " Language: SystemVerilog " Maintainer: Stephen Hobbs <stephenh@ ...

  6. WordPress版微信小程序2.6版发布

    WordPress版微信小程序的完善和升级的工作一直都在进行中,我争取保证一个月可以出一个版本,希望通过一点点的改进,让这个开源产品日趋完美. 同时,pro版WordPress微信小程序也在紧锣密鼓的 ...

  7. tomcat9配置https

    首先去阿里云申请一个pfx证书,可以免费获得. 其次,在tomcat的server.xml增加如下connector <Connector port="443" protoc ...

  8. 在VS2015中用C++编写可被C#调用的DLL

    VS2015用C++创建动态库DLL步骤如下: (1)启动VS2015-->文件-->新建-->项目,按图二进行选择,选择Win32项目,弹出创建窗口,如第二张图.注意.net版本根 ...

  9. webstorm2016.3注册码,License server更新方式,webstorm2017.1版本可用

    以前的webstorm和phpstorm的激活码和地址,今天打开的时候过期了 (your license has expored) 以前是用activation code的更新方式: 后来搜了下,换个 ...

  10. json文件转换成excel

    1.环境 python2.7 2.库 xlwt.demjson.json 3.code # -*- coding: utf-8 -*- import xlwt,demjson,json if __na ...