#include #include #include #include #define MAX 16384 #define EPS 1e-5 struct vector { double x,y; int uhel; }; vector a[2*MAX]; int pravy[MAX]; int n,c; void recompute(int index) { vector &levy=a[2*index]; vector &pravy=a[2*index+1]; //prepocteme uhly a[index].uhel=levy.uhel+pravy.uhel; // a[2*index], a[2*index+1] if (pravy.x==0.0 && pravy.y==0.0) a[index]=a[2*index]; else { // printf("Rec at %d, uhel %d\n",index,levy.uhel); double uhel=levy.uhel*3.1415926535/180.0; double c=cos(uhel),s=sin(uhel); a[index].x=levy.x+pravy.x*c-pravy.y*s; a[index].y=levy.y+pravy.x*s+pravy.y*c; } if (index>1) recompute(index/2); } int main(void) { int first=1; for (int i=MAX-1;i>0;i--) { int p=2*i+1; while (p0;i--) { a[i].uhel=0; a[i].x=0; a[i].y=a[2*i].y+a[2*i+1].y; } while (c--) { int kloub,uhel; scanf("%d %d",&kloub,&uhel); a[MAX+kloub-1].uhel=uhel-180; recompute((MAX+kloub-1)/2); printf("%.2f %.2f\n",a[1].x+EPS,a[1].y+EPS); } } return 0; }