ZOJ Problem Set - 3737
The developers got a wonderful rectangular field with length n meters and width m meters. They wanted to build a theme park on this field. First of all, they had to level this field. A group of surveyors made a survey of this field. Firstly, they divide the rectangle field into many small squares. The method is like this: divide the length equally into n pieces, and divide the width equally into m pieces. Then the field would be divided into n*m small squares whose size were 1 meter * 1 meter. Then the surveyors measured the elevations of the four corners and the center of these little squares. Now, if we connected the center and the four corners of each little square, the field would be divided into many triangles. We can regard this field being consisted by many truncated triangular prisms, so that some parameters, such as the volume, can be easily calculated. The architect designed that the field should be leveled to meet the elevations of h. The civil engineer was ordered to calculate how much clay should be digged out and how much clay should be filled in. He found it difficult to finish this mission by hand. Can you help him?
There are several test cases.
For each test case, you should output one line, contains two real number separated by a single space, first number is the volume of the clay should be digged out, and the second number is the volume of the clay should be filled in. Each of the numbers should be round to 3 digits after decimal point.
1 1 1.5 1.5 2.5 0.5 1.5 1.5 1 1 1.2 1.5 2.5 0.5 1.5 1.5
0.167 0.167 0.357 0.057
Author: LI, Tierui
Contest: ZOJ Monthly, December 2013