1 #include <cstdio> 2 #include <cstring> 3 #include <iostream> 4 #include <stack> 5 #include <queue> 6 #include <map> 7 #include <algorithm> 8 #include <vector> 9 #include <cmath> 10 #define pi 3.141592653 11 using namespace std; 12 13 const int maxn = 40005; 14 15 16 typedef long long LL; 17 18 int N,C; 19 int L[maxn]; 20 int S[maxn],A[maxn]; 21 22 double vx[maxn],vy[maxn]; 23 double ang[maxn]; 24 double pre[maxn]; 25 26 void init(int l,int r,int rt) 27 { 28 ang[rt] = vx[rt] = 0.0; 29 if(r - l == 1) { 30 vy[rt] = L[l]; 31 } 32 else{ 33 int lch = rt*2+1; 34 int rch = rt*2+2; 35 int mid = (r + l )/2; 36 init(l,mid,lch); 37 init(mid,r,rch); 38 vy[rt] = vy[lch] + vy[rch]; 39 } 40 } 41 42 void change(int s,double a,int rt,int l,int r) 43 { 44 if(s <= l) return ; 45 else if(s < r){ 46 int lch = rt*2+1; 47 int rch = rt*2+2; 48 int mid = (l + r)/2; 49 change(s,a,lch,l,mid); 50 change(s,a,rch,mid,r); 51 if(s <= mid) ang[rt] += a; 52 double t = sin(ang[rt]); 53 double c = cos(ang[rt]); 54 vx[rt] = vx[lch] + (c*vx[rch] - t*vy[rch]); 55 vy[rt] = vy[lch] + (t*vx[rch] + c*vy[rch]); 56 } 57 } 58 59 void solve() 60 { 61 init(0,N,0); 62 for(int i=1;i<N;i++) pre[i] = pi; 63 for(int i=0;i<C;i++){ 64 int s = S[i]; 65 double a = A[i]/360.0*2*pi; 66 change(s,a-pre[s],0,0,N); 67 pre[s] = a; 68 printf("%.2f %.2f ",vx[0],vy[0]); 69 } 70 } 71 72 int main() 73 { 74 while(scanf("%d%d",&N,&C)!=EOF){ 75 for(int i=0;i<N;i++){ 76 scanf("%d",&L[i]); 77 } 78 for(int i=0;i<C;i++){ 79 scanf("%d%d",&S[i],&A[i]); 80 } 81 solve(); 82 } 83 84 return 0; 85 }