CC4 -Editorial

PROBLEM LINK

RIHANNA AND TRIANGLES

DIFFICULTY

EASY

PROBLEM

Given the number of lines and the number of parallel lines in each set, you have to find the total number of triangles formed.

EXPLANATION

Total number of triangles that can be formed with n lines without any parallel lines is nC3. Now if we consider parallel lines, we cannot form a triangle if all three lines chosen are parallel to each other or any of the two lines in chosen three line are parallel. Now we have to subtract these triangle, since they cannot form a triangle.
No.of triangles =nC3-(((n-m1)*m1C3)+m1C3)- (((n-m2)*m2C3)+m2C3)… etc for all parallel sets.

2 Likes

Considering m1, m2 etc… to be a set of parallel lines, shouldn’t the equation be nC3-(((n-m1)m1C2)+m1C3)- (((n-m2)m2C2)+m2C3) and so on?