UVa 11854

From Algorithmist
Jump to navigation Jump to search

11854 - Egypt[edit]

Summary[edit]

Determining if a triangle is a right triangle or not, lengths of the 3 sides of the triangle are given. Just implementation of Pythagorean theorem.

Explanation[edit]

Pythagorean theorem states that the square of the hypotenuse (the side opposite the right angle) is equal to the sum of the squares of the other two sides. The theorem can be written as an equation relating the lengths of the sides a, b and c, often called the "Pythagorean equation": a^2 + b^2 = c^2 , where c represents the length of the hypotenuse and a and b the lengths of the triangle's other two sides.

So, here a, b, c are given, just check if the value of a, b, c satisfies the Pythagorean theorem or not.

Notes[edit]

Simple 32-bit integer data type can be implemented as the input values are positive integers, less than 30000 .

Implementations[edit]

The input values may not be in sorted order, so, any of the three values can be the length of the hypotenuse. So, check for all the three values.

Optimizations[edit]

Not necessary to use library function to calculate the square of any value, just simply multiply the value by itself.

Input[edit]

6 8 10
25 52 60
5 12 13
0 0 0

Output[edit]

right
wrong
right

References[edit]

References for Pythagorean theorem: http://en.wikipedia.org/wiki/Pythagorean_theorem

Solutions[edit]