editorial needed for INSQ17E

cannot understand the approach…
would be grateful if someone could help me out in this problem

Let us assume that we have a set of m points such that no two lines passing through them are parallel.

Since, between each pair of m points, \exists a unique line, \therefore total number of lines, M = m \choose 2.

And, since no two lines are parallel, they intersect at exactly one point \therefore total number of points = M \choose 2

But, we have counted some points more than once.

From the figure, we can see that from each of the m points, (m-1) lines pass. If this wasn’t the case then these (m-1) lines would have added m-1 \choose 2 points, but they didn’t.

Thus, we have to remove these points from our answer.

So, the answer becomes M \choose 2 $-\ m \times\

m-1\choose 2$ which reduces to

\dfrac{m(m-1)(m-2)(m-3)}{8}

Here is the accepted code in Python. [https://www.codechef.com/viewsolution/15264997][1] [1]: https://www.codechef.com/viewsolution/15264997
2 Likes

why are u multiplying (m-1)C(2)…couldn’t understand…pls elaborate

//