There are ‘n’ points in a plane out of which ‘m points are collinear. How many different straight lines can form?
Input : n = 3, m = 3 Output : 1 We can form only 1 distinct straight line using 3 collinear points Input : n = 10, m = 4 Output : 40
Number of distinct Straight lines = nC2 – mC2 + 1
How does this formula work?
Consider the second example above. There are 10 points, out of which 4 collinear. A straight line will be formed by any two of these ten points. Thus forming a straight line amounts to selecting any two of the 10 points. Two points can be selected out of the 10 points in nC2 ways.
Number of straight line formed by 10 points when no 2 of them are co-linear = 10C2…..…(i)
Similarly, the number of straight lines formed by 4 points when no 2 of them are co-linear = 4C2….(ii)
Since straight lines formed by these 4 points are sane, straight lines formed by them will reduce to only one.
Required number of straight lines formed = 10C2– 4C2 + 1 = 45 – 6 + 1 = 40
Implementation of the approach is given as:
- Count of triangles with total n points with m collinear
- Check if three straight lines are concurrent or not
- Represent a given set of points by the best possible straight line
- Program to check if three points are collinear
- Number of triangles in a plane if no more than two points are collinear
- Maximum points of intersection n lines
- Minimum lines to cover all points
- Non-crossing lines to connect points in a circle
- Number of triangles formed from a set of points on three lines
- Count of obtuse angles in a circle with 'k' equidistant points between 2 given points
- Count maximum points on same line
- Queries on count of points lie inside a circle
- Count Integral points inside a Triangle
- Minimum number of points to be removed to get remaining points on one side of axis
- Ways to choose three points with distance between the most distant points <= L
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.