#P2807. Counting Triangles in a Subdivided Triangle
Counting Triangles in a Subdivided Triangle
Counting Triangles in a Subdivided Triangle
Given a large triangle, each of its sides is divided into n equal parts. Then, for each side, the corresponding division points are connected by lines parallel to the triangle's sides. This process partitions the triangle into many smaller triangles. Your task is to calculate the total number of triangles that appear in the diagram.
The result can be expressed using the following formula in LaTeX:
$$\left\lfloor \frac{n(n+2)(2n+1)}{8} \right\rfloor$$
Here, \lfloor x \rfloor
denotes the floor of x.
inputFormat
The input consists of a single integer n (1 ≤ n ≤ 104), representing the number of equal divisions on each side of the triangle.
outputFormat
Output a single integer representing the total number of triangles formed in the diagram.
sample
1
1