Building Pyramids
Time limit1sMemory limit1024 MB
Given n, the number of spheres on one edge of a tetrahedral stack, output the total number of spheres in the pyramid.
- Level
Easy2 of 10
- Topics
- Math, Implementation
- Solved
- No attempts yet
Problem
At long last, the cats have finally set aside their squabbles with the coatis and the bees. They decide to build a monument to commemorate the end of their feud. To show that such different animals can live together in harmony, the Great Architect Principal Coati decides that this monument should consist of two completely different three-dimensional shapes: the triangular pyramid (for having very sharp corners) and the sphere (for having no corners at all). The idea is to create a large regular tetrahedron out of many small spheres, similar to the one shown in Figure B.1.

Figure B.1: A triangular pyramid of spheres, corresponding to the second sample input. One edge of the pyramid contains spheres, so the entire pyramid consists of spheres.
Image CC BY-NC 2.0 by Amafirlian on Flickr
Alicia the coati, Beesworth the bee, and Darabella the cat would like this monument to be as large as possible. They have designated a piece of land to place the monument on, and have determined how many spheres should be in one of the edges based on where the monument will be placed. How many spheres will the entire pyramid contain, knowing the number of spheres in one of the edges?
Input
The first line contains one integer (), the number of spheres in one of the edges of the pyramid.
Output
Output the number of spheres in the entire pyramid.