#P7900. Counting Intersection Points of Diagonals in a Convex Polygon
Counting Intersection Points of Diagonals in a Convex Polygon
Counting Intersection Points of Diagonals in a Convex Polygon
Given a convex polygon with n
vertices, where no three or more diagonals intersect at a single point, determine the number of intersection points produced by the diagonals. The answer can be derived from the formula:
$$ \binom{n}{4} = \frac{n \times (n-1) \times (n-2) \times (n-3)}{24} $$
Note that if n < 4
, no intersection is possible, and the output should be 0.
inputFormat
The input consists of a single integer n
representing the number of vertices of the convex polygon.
outputFormat
Output a single integer which is the number of intersection points among the diagonals of the convex polygon.
sample
3
0