poj 2991 Crane
来源:互联网 发布:怎么取消数据有效性 编辑:程序博客网 时间:2024/05/18 21:50
#include<stdio.h>#include<math.h>#include<string.h>#define PI acos(-1.0)#define N 10011#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1double sx[N<<2],sy[N<<2];int sd[N<<2],degree[N];void pushup(int rt){sx[rt]=sx[rt<<1]+sx[rt<<1|1];sy[rt]=sy[rt<<1]+sy[rt<<1|1];}void rotate(int rt,int sd){double d,x,y;d=sd*asin(1.0)/90.0;x=cos(d)*sx[rt]-sin(d)*sy[rt];y=sin(d)*sx[rt]+cos(d)*sy[rt];sx[rt]=x;sy[rt]=y;}void pushdown(int rt){rotate(rt<<1,sd[rt]);rotate(rt<<1|1,sd[rt]);sd[rt<<1]+=sd[rt];sd[rt<<1|1]+=sd[rt];sd[rt]=0;}void build(int l,int r,int rt){int m;sd[rt]=0;if(l==r){scanf("%lf",&sy[rt]);sx[rt]=0;return ;}m=(l+r)>>1;build(lson);build(rson);pushup(rt);}void update(int p,int d,int l,int r,int rt){int m; if(p<l) { rotate(rt,d); sd[rt]+=d; return ; } if(sd[rt]) pushdown(rt); m=(l+r)>>1; if(p<m) update(p,d,lson); update(p,d,rson); pushup(rt);}int main(void){int i,j,n,m,flag=0;while(~scanf("%d%d",&n,&m)){build(1,n,1);for(i=1;i<=n;i++)degree[i]=180;while(m--){scanf("%d%d",&i,&j);update(i,j-degree[i],1,n,1);degree[i]=j;printf("%.2lf %.2lf\n",sx[1],sy[1]);}printf("\n");}}
0 0
- poj 2991 Crane
- POJ 2991 - Crane
- POJ 2991 Crane
- poj 2991-Crane
- POJ 2991 Crane
- poj 2991crane
- 挑战 POJ.2991 Crane
- POJ 2991 Crane
- poj 2991 Crane
- POJ 2991:Crane
- POJ 2991 Crane 笔记
- POJ 2991 Crane 线段树
- 线段树 POJ 2991Crane
- poj 2991 Crane(线段树)
- POJ 2991 Crane (线段树)
- POJ 2991 Crane 线段树
- 【POJ 2991 Crane】+ 线段树
- poj crane
- LCD硬件操作
- 依赖注入框架dagger2的@Scope注解初探(根据生成的源码进行分析)
- Android Studio 技巧之【Extract Parameter】
- Python基础入门教程(4)(数据类型)
- [jQuery EasyUI系列] 创建增删改查应用
- poj 2991 Crane
- activiti工作流视频教程
- Where Softirq Is Invoked
- GC可达性实践-内存泄露分析
- 关于二分查找
- 由浅入深学C# 视频教程
- Spring MVC + Security 4 初体验(Java配置版)
- PHP关于input里面设置输入值
- 栈