Crossing Prisms#3203

Crossing Prisms

1 second
64 megabytes
Medium

Prof. Bocchan is a mathematician and a sculptor. He likes to create sculptures with mathematics.

His method of making sculptures is quite unique. He uses two identical prisms, crossing them at right angles, creating a polyhedron as the intersection, which he finishes by painting. Therefore, he needs to know the surface area of this polyhedron to estimate the amount of pigment required.

For example, consider two identical prisms as shown in Figure 1. The definition of their cross section is given in Figure 2. The prisms are placed at right angles to each other, and their intersection forms the polyhedron shown in Figure 3. An approximate value for the surface area is 194.8255.

Figure 1.

Given the cross-section of the two identical prisms, your task is to compute the surface area of the resulting sculpture.

Input

The input consists of several datasets, followed by a single line containing only a zero. The first line of each dataset contains an integer , which specifies the number of the following lines. Each of these lines contains two integers a_i and b_i (i = 1, \ldots, n).

A closed path formed by the points (a_1, b_1), (a_2, b_2), \ldots, (a_n, b_n), (a_{n+1}, b_{n+1}) = (a_1, b_1) defines the outline of the cross-section of the prisms. This closed path is simple; that is, it does not cross or touch itself. The right side of the segment from (a_i, b_i) to (a_{i+1}, b_{i+1}) is the interior of the section.

You may assume that 3 \le n \le 4, 0 \le a_i \le 10, and 0 \le b_i \le 10 (i = 1, \ldots, n).

One prism is placed along the -axis so that the cross-section at x = E is represented by the points (x_i, y_i, z_i) = (E, a_i, b_i) (0 \le E \le 10, i = 1, \ldots, n). The other prism is placed along the -axis so that its cross-section at y = F is represented by the points (x_i, y_i, z_i) = (a_i, F, b_i) (0 \le F \le 10, i = 1, \ldots, n).

Output

The output should consist of a sequence of lines, each containing a single decimal number. Each number should be an approximate value of the surface area of the polyhedron defined by the corresponding input dataset. The error must be less than or equal to 0.0001. You may print any number of digits after the decimal point.

Examples

Example 1

Loading
Loading