#include #include #include using namespace std; #define point pair #define deg_to_rad (3.1415926 / 180) int main() { // Where we are double x = 0.0; double y = 0.0; // Where we are facing double facing = 0.0; // The new readings double dist, angle; // Where we've been, now in cartesian vector points; // Note where we started points.push_back(point(0.0, 0.0)); // Read the info while (cin >> dist >> angle) { // Move x and move y (the 12 is to convert inches to feet) x += dist * sin(facing * deg_to_rad) / 12; y += dist * cos(facing * deg_to_rad) / 12; // Break if we are done if (angle == 0) break; // Note where we are points.push_back(point(x, y)); // And change the facing for next time facing += angle; } // now we count up the area: the area of n + 1 points is // 1 .. n: delta x * avg y (this overcounts in some cases, but // then subtracts off the overcount on the way back. Very nice actually.) double area = 0.0; // Do the loop for (int i = 0; i < points.size() - 1; i++) { // Add the area of this trapezoid area += (points[i + 1].first - points[i].first) * (points[i + 1].second + points[i].second) / 2; } // Round and make sure the area is positive cout << abs(round(area)) << endl; }