Given three parallel straight lines *l1*, *l2* and *l3* lying in the same plane. Total numbers of *m*, *n* and *k* points lie on the line *l1*, *l2*, *l3* respectively. This article aims to find the maximum number of triangles formed with vertices at these points.

**Examples:**

Input :m = 14, n = 34, k = 114

Output :448708.0

Input :m = 95, n = 77, k = 94

Output :2755951.0

**Approach-**

- Total number of triangle =
- Number of triangle that is not valid traingle from l1 plane =
- Number of triangle that is not valid traingle from l2 plane =
- Number of triangle that is not valid traingle from l3 plane =
- so number of valid Triangle =

**Below is the Python code implementation of the approach.**

`# Pyton code implementation ` `import` `math ` `def` `nooftriangle(m, n, k): ` ` ` ` ` `# r1 = (m + n + k)C3 ` ` ` `r1 ` `=` `math.factorial(m ` `+` `n ` `+` `k) ` `/` `( ` ` ` `math.factorial(` `3` `) ` `*` `math.factorial(m ` `+` `n ` `+` `k ` `-` `3` `)) ` ` ` `# r2 = mC3 ` ` ` `r2 ` `=` `math.factorial(m) ` `/` `(math.factorial(` `3` `) ` `*` `math.factorial(m ` `-` `3` `)) ` ` ` ` ` `# r3 = nC3 ` ` ` `r3 ` `=` `math.factorial(n) ` `/` `(math.factorial(` `3` `) ` `*` `math.factorial(n ` `-` `3` `)) ` ` ` ` ` `#r4 = kC3 ` ` ` `r4 ` `=` `math.factorial(k) ` `/` `(math.factorial(` `3` `) ` `*` `math.factorial(k ` `-` `3` `)) ` ` ` ` ` `result ` `=` `r1 ` `-` `r2 ` `-` `r3 ` `-` `r4 ` ` ` `return` `(result) ` ` ` `# Driver code ` `m ` `=` `17` `n ` `=` `16` `k ` `=` `11` `print` `(` `"Number of traingles : "` `, nooftriangle(m, n, k)) ` ` ` |

*chevron_right*

*filter_none*

**Output:**

Number of traingles : 11839.0

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.

## Recommended Posts:

- Number of triangles formed from a set of points on three lines
- 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
- Python - Convert simple lines to bulleted lines using the Pyperclip module
- Number of lines from given N points not parallel to X or Y axis
- Maximum points of intersections possible among X circles and Y straight lines
- Number of triangles in a plane if no more than two points are collinear
- Find whether only two parallel lines contain all coordinates points or not
- Number of pairs of lines having integer intersection points
- Find the point on X-axis from given N points having least Sum of Distances from all other points
- Forming triangles using points on a square
- Find the maximum value of Y for a given X from given set of lines
- Check if three straight lines are concurrent or not
- Equation of circle when three points on the circle are given
- Check whether triangle is valid or not if three points are given
- Number of Integral Points between Two Points
- Prime points (Points that split a number into two primes)
- Number of quadruples where the first three terms are in AP and last three terms are in GP
- Maximum count of Equilateral Triangles that can be formed within given Equilateral Triangle
- Find minimum value of y for the given x values in Q queries from all the given set of lines

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.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.