Triangles from Five Sticks
InterviewTime limit2sMemory limit512 MB
Given five distinct stick lengths, count how many 3-stick subsets can form a triangle with positive area.
- Level
Easy2 of 10
- Topics
- Brute force, Geometry, Implementation
- Solved
- No attempts yet
Problem
Vera has five sticks, and no two of them have the same length. The lengths are . Vera may pick any three of them and use the three sticks as the sides of a triangle. The sticks cannot be bent or cut, and the triangle must have positive area.
How many different triangles can Vera make?
Input
The first line contains the integers separated by spaces. ()
Output
Print the number of ways to form a triangle as a single integer on one line.
Hint
In the first example the three triangles come from the lengths 2, 3, 4 and 2, 4, 5 and 3, 4, 5.