DWITE Online Computer Programming Contest
October 2007
Problem 2
Cubes in a Pyramid
A pyramid is to be constructed out of stone cubes, 1 meter in length each. The pyramid will have a square base, and will be completely solid. Given the dimensions for the length of the base, and the height of the pyramid, and assuming that no material is wasted, calculate the minimum number of cube stones required to construct a pyramid of the supplied dimensions.
Input
Two lines. The first contains the real number L (0 < L ≤ 100), the length of the pyramid's base. The second contains the real number H (0 < H ≤ 100), the pyramid's height.Output
A single integer, the minimum number of blocks required for the construction.Sample Input
10.0 5.0
Sample Output
167
Hint: The volume of a pyramid is V = 1/3 A*h, where A is the area of the base and h is the height.
All Submissions
Best Solutions
Point Value: 5
Time Limit: 2.00s
Memory Limit: 16M
Added: Mar 19, 2010
Languages Allowed:
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3
Comments (Search)