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)

my code works with the samples, why is it only getting 60 when i submit it?

did you use the print(int(variable) in which it rounds the number so that it becomes 167 instead of 166.666...?

also if its not working check what the peg judge says, if its says traceback or a.out line normally its a syntax error

print(int(variable) only rounds to 166, and there is no syntax error, can someone look at my code and tell me whats wrong?

my code is correct, its just that i cant round the output(e.g. output=166.666666...)

Even when using round command, with floats, i get 166.66666...

Ive also been researching the round() command in python and string formatting, it itself, and even other commands (e.g. import decimal) isnt working!

Hey Venkat, when rounding in python3, you can do "print(int(V)"(in your case).

Research the % operator.