TopCoder problem "TriangleType" used in SRM 247 (Division II Level One)



Problem Statement

    In Euclidean Geometry, triangles can be categorized into one of three types based on their angle measures. A triangle is acute if all three angles are less than 90 degrees. A triangle is obtuse if one angle is greater than 90 degrees. Lastly, a triangle with one angle at exactly 90 degrees is a right triangle.



It could also be the case that three positive integers can not possibly form the side-lengths of a triangle. This happens when the length of one side is equal to or larger than the sum of the lengths of the other two sides, because it would not be possible to connect the end points of the three sides in such a way that a triangle was formed.



Write a method that takes as input three positive integer side-lengths of a triangle. Return "IMPOSSIBLE" if a triangle cannot be formed. Return "ACUTE" if the triangle is acute, "OBTUSE" if the triangle is obtuse, and "RIGHT" if the triangle is right.
 

Definition

    
Class:TriangleType
Method:type
Parameters:int, int, int
Returns:String
Method signature:String type(int a, int b, int c)
(be sure your method is public)
    
 

Notes

-For a triangle with side-lengths x, y, and z and x <= y <= z.

* The triangle is right if x*x + y*y = z*z.

* The triangle is obtuse if x*x + y*y < z*z.

* The triangle is acute if x*x + y*y > z*z.

* It is impossible to have x + y <= z.
 

Constraints

-a, b, and c are between 1 and 10,000, inclusive.
 

Examples

0)
    
3
4
5
Returns: "RIGHT"
1)
    
3
4
4
Returns: "ACUTE"
2)
    
3
4
6
Returns: "OBTUSE"
3)
    
7
4
3
Returns: "IMPOSSIBLE"

Problem url:

http://www.topcoder.com/stat?c=problem_statement&pm=4610

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=7222&pm=4610

Writer:

lars2520

Testers:

Problem categories:

Simple Math