Every summer, the manager of Starving Students General Contractor
hires local college students to assist with various tasks around
construction sites. Ordinarily he hires engineering students to
assist with the measurements for laying carpet and other floor
coverings. Each year, without any special instruction, the engineers
would head out to the new houses and return with annotated floor plans
with each measurement marked according to Figure 6.1. The manager
then submitted these drawings to the carpet supplier who calculated the
area from the drawings.
This year, however, he had so much business that he started hiring
math students to measure for floor covering. As with the engineers,
he sent the mathematicians out to the houses with no special
training. Rather than returning with detailed floor plans, the math
students submitted lists of connected vectors. The vectors recorded
the length of a wall and the angle that the adjacent wall made with
respect to the current wall.
After his initial appraisal of the work as unusable he realized his
good fortune: if he could obtain a computer program to interpret this
information, he could calculate the area to verify that the carpet
supplier was not inflating the areas for illicit profit. To solve the
problem, the manager reassigned several computer science students
(your team), who were quite bored writing Excel macros for the finance
department. Fortunately, the math students always measured in closed
loops, working their way clockwise through the insides of the
houses.
Input to your program is a list of wall measurements, one segment per
input line. Each measurement begins wit ha wall length, in inches,
followed by whitespace, then an angle in degrees that represents the
"turn" that the math students made to measure the adjacent wall. A
left turn is measured positive and a right turn is measured negative.
The final segment that closes the loop is marked with 0 degrees. The
sample input represents the measurements in Figure 6.1. No houses
have more than 100 walls. Angle measurements are in the range
[-179.0, 179.0] degrees.
Output is a single number representing the square feet of area
enclosed by the wall measurements. Round the area to the nearest
square foot.
![](house.png)
Sample input
Sample output