//线段树 延迟标签
//
#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. ActionFilterAttribute 全局记录API日志

    1.API项目下创建MonitorApiAttribute public class MonitorApiAttribute : ActionFilterAttribute { private sta ...

  2. java.lang.Byte 类源码浅析

    Byte 类字节,属于Number. public final class Byte extends Number implements Comparable<Byte> { /** * ...

  3. projective dynamics的global solve中 引入拉格朗日乘子的简化方法

    想了一下使用乘子法还是可行的/做一个简化.在约束C(xn) 在C(xn-1)处线性展开 (n是时间步骤)具体推导留作备份等有时间了去代码实现 3式是一个典型的LCP问题 用PGS就行 左边的系数部分依 ...

  4. http(数据格式)、postman(数组、id、断言) 小知识必看啊

  5. JVM-索引

    JVM内容梳理 JVM体系结构 Jvm的体系结构 JVM内存区域详解(Eden Space.Survivor Space.Old Gen.Code Cache和Perm Gen) JVM之堆内存(年经 ...

  6. webpy学(ban)习(砖)记录

    参考链接:http://blog.csdn.net/caleng/article/details/5712850 参考代码:http://files.cnblogs.com/files/tacyeh/ ...

  7. 灰熊:在这6个信息流和DSP平台投放后,我总结了这些血泪经验!

    笔者有幸参与公司的一款重度游戏的推广,推广以来市面上主流的信息流和DSP 平台都投过一番,今天就零零碎碎地讲讲各个平台的特点以及用户质量. 需要提前说明的是,文章的观点仅限于各个平台的 iOS 流量, ...

  8. PG数据库——视图

    视图(View)是从一个或多个表(或视图)导出的表.视图与表(有时为与视图区别,也称表为基本表——Base Table)不同,视图是一个虚表,即视图所对应的数据不进行实际存储,数据库中只存储视图的定义 ...

  9. 关于vue

    render:(h)=>h(App):声明App组件的内容 挂载到节点 const root=document.createElement("div")document.bo ...

  10. 使用 nodeJs 开发微信公众号(配置服务器)

    流程如下: 1. 申请微信公众号:企业号.服务号.订阅号(前两个要钱) 2. 配置微信公众号后台 选择基本配置,获得 AppId 和 AppSecret ,点击服务器配置 URL:你服务器地址,不能是 ...