#include #include #include #include #include # define M_PI 3.14159265358979323846 /* pi */ #define MAX 10001 double cranex[MAX], craney[MAX]; double a_sin[360], a_cos[360]; int engls[MAX]; int N; void print() { char buf1[50], buf2[50], *b1, *b2; sprintf( buf1, "%.2f", cranex[N] ); sprintf( buf2, "%.2f", craney[N] ); b1 = strcmp("-0.00", buf1) ? buf1 : buf1+1; b2 = strcmp("-0.00", buf2) ? buf2 : buf2+1; printf("%s %s\n", b1, b2 ); } void rotabout( double x, double y, int by, int i ) { double ox, oy, nx, ny; ox = cranex[i]-x; oy = craney[i]-y; nx = ox*a_cos[by] - oy*a_sin[by]; ny = ox*a_sin[by] + oy*a_cos[by]; cranex[i] = nx + x; craney[i] = ny + y; } void rot( int s, int a ) { int i; int by = a-engls[s]; if (by < 0) by += 360; for ( i = s+1; i <= N; ++i ) { rotabout( cranex[s], craney[s], by, i ); } } int main() { int i, l, c, sep = 0; for ( i = 0; i < 360; ++i ) { a_sin[i] = sin((i*M_PI)/180); a_cos[i] = cos((i*M_PI)/180); } while (scanf( "%d %d", &N, &c ) == 2) { if (sep) puts(""); else sep = 1; memset( cranex, 0, sizeof(cranex) ); for ( i = 1; i <= N; ++i ) { scanf( "%d", &l ); engls[i] = 180; craney[i] = craney[i-1] + l; } while (c--) { int s, a; scanf( "%d %d", &s, &a ); rot( s, a ); print(); } } return 0; }