Given three integers m, n and k that store the number of points on lines l1, l2 and l3 respectively that do not intersect. The task is to find the number of triangles that can possibly be formed from these set of points.
Input: m = 3, n = 4, k = 5 Output: 205 Input: m = 2, n = 2, k = 1 Output: 10
- The total number of points are (m + n + k) which must give
number of triangles.
- But ‘m’ points on ‘l1’ gives
combinations which cannot form a triangle.
and number of triangles can not be formed.
- Therefore, Required Number of Triangles =
Below is the implementation of the above approach:
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Python - Find the maximum number of triangles with given points on three lines
- Number of Triangles that can be formed given a set of lines in Euclidean Plane
- Total number of triangles formed when there are H horizontal and V vertical lines
- Number of triangles that can be formed with given N points
- Area of the largest rectangle formed by lines parallel to X and Y axis from given set of points
- Number of triangles in a plane if no more than two points are collinear
- Count rectangles generated in a given rectangle by lines drawn parallel to X and Y axis from a given set of points
- Number of triangles formed by joining vertices of n-sided polygon with one side common
- Number of triangles formed by joining vertices of n-sided polygon with two common sides and no common sides
- Number of pairs of lines having integer intersection points
- Number of lines from given N points not parallel to X or Y axis
- Forming triangles using points on a square
- Count of triangles with total n points with m collinear
- Check if three straight lines are concurrent or not
- Maximum count of Equilateral Triangles that can be formed within given Equilateral Triangle
- Count of different straight lines with total n points with m collinear
- Maximum points of intersection n lines
- Find whether only two parallel lines contain all coordinates points or not
- Maximum points of intersections possible among X circles and Y straight lines
- Number of quadruples where the first three terms are in AP and last three terms are in GP
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.