![]() |
||||||||||
|
||||||||||
Tetrahedral Stacks of CannonballsTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 454 Accepted Submission(s): 13 Problem Description ![]() ![]() In Civil War memorials with cannons and stacks of cannonballs, the cannonballs were sometimes stacked as a four-sided pyramid, with the base as a square of cannonballs with n balls on each side. An alternative is to stack them in a three-sided pyramid, which is in fact one of the Platonic solids, a tetrahedron. This tetrahedron of cannonballs has a base that is an equilateral triangle of cannonballs with n balls on each side. The number of balls in that triangle is given simply by adding together the numbers from 1 to n. On top of each layer (starting from the base) is a triangle with one less ball on each side, up to the top-most layer with a single ball. Given the number of cannonballs on each side of the base, compute the total number of cannonballs in the entire tetrahedral stack. Input The first line contains a single number n, giving the number of tetrahedral problems posed, for a maximum of 100 problems. Following that are exactly n lines, each with a single number giving the number of cannonballs on each side of the base for a tetrahedron of cannonballs, a number greater than 0 and less than 1000. Output For each problem, output the problem number (starting from 1), a colon and a blank, the number of cannonballs on each side of the base, one blank, and finally the total number of cannonballs in the tetrahedron. Sample Input
Sample Output
Source | ||||||||||
|