// UVa 11505 - Logo #include <math.h> #include <iostream> #include <string> #include <stdio.h> using namespace std; int main() { int t; for (cin >> t; t; t--) { double alpha = 0, x = 0, y = 0; int n; for (cin >> n; n; n--) { string command; double param; cin >> command >> param; if (command == "fd" || command == "bk") { int sign = (command == "fd") ? 1 : -1; x += cos(alpha / 180 * M_PI) * sign * param; y += sin(alpha / 180 * M_PI) * sign * param; } else if (command == "lt" || command == "rt") { int sign = (command == "lt") ? 1 : -1; alpha += param * sign; } } double sol = sqrt(x * x + y * y); printf("%.0f\n", sol); } return 0; }
Saturday, May 16, 2015
UVa 11505 - Logo
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment