#P7918. Minimum Line Selection to Cover All Intersections
Minimum Line Selection to Cover All Intersections
Minimum Line Selection to Cover All Intersections
In a two-dimensional Cartesian coordinate system, there are n lines such that no two lines coincide and no three lines are concurrent (i.e. no three lines pass through the same point). In such a configuration, every pair of lines intersect (assuming n ≥ 2) and they form at most $$\frac{n(n-1)}{2}$$ distinct intersection points. A point is said to be covered if at least one of the selected lines goes through it.
Your task is to determine the minimum number of lines that must be selected to cover all intersection points. Note that if n = 1, there is no intersection point, so the answer is 0.
inputFormat
The input consists of a single integer n
(1 ≤ n ≤ 109), which indicates the number of lines in the plane.
outputFormat
Output a single integer representing the minimum number of lines needed to cover every intersection point.
sample
1
0