High Towers

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

요약
높이 n인 삼각형 격자 그림에서 위를 향하는 삼각형의 개수를 구한다. n은 최대 200만이다.
난이도

보통10점 중 4점

유형
조합론, 수학
정답자
아직 제출이 없습니다

문제

Peter really likes to solve puzzles and his friends know this. They recently asked Peter to solve a well-known puzzle: given a triangular figure of height 33 (see the figure right), how many triangles pointing upwards are in the figure? Peter solved this problem in no-time so he asked his friends for some harder puzzles. And they came up with the same figure of height 44 and height 55 which Peter easily solved.

However, Peter got himself in a bit of trouble when his friends want him to solve the puzzle with a figure of height 66. Peter still wants to impress his friends with the correct answer, and he wants to be able to solve the puzzles with an even greater height, possibly up to two million! Since he's a very bad programmer, he asked you for help: given the height of the triangle nn, can you determine how many triangles pointing upwards there are visible in the figure?

Figure 1 - A triangle puzzle with height 3. There are 10 upward triangles in this figure.

입력

The input consists of one integer nn (1≤n≤2⋅1061 \leq n \leq 2 \cdot 10^6): the height of the triangle.

출력

One integer with the number of triangles pointing upwards in the figure.

예제2

  1. 예제 1

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

    입력
    83948
    
    예상 출력
    98604181205900