Building Pyramids

면접 대비

시간 제한1초메모리 제한1024 MB

요약
구 모양 삼각뿔에서 한 모서리에 놓인 구의 개수 n이 주어질 때, 전체 삼각뿔에 들어 있는 구의 총 개수를 구한다.
난이도

쉬움10점 중 3점

유형
수학, 조합론, 구현, 완전 탐색
정답자
아직 제출이 없습니다

문제

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 55 spheres, so the entire pyramid consists of 3535 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?

입력

The input consists of:

  • One line with an integer nn (1≤n≤1061\leq n\leq 10^6), the number of spheres in one of the edges of the pyramid.

출력

Output the number of spheres in the entire pyramid.

예제3

  1. 예제 1

    입력
    3
    
    예상 출력
    10
    
  2. 예제 2

    입력
    5
    
    예상 출력
    35
    
  3. 예제 3

    입력
    7777
    
    예상 출력
    78424644529