Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Pythagoras Rocks

Limits 1s, 512 MB

Most of us were introduced with Pythagoras’s theorem back at the high school. It states a simple yet fascinating fact about right triangles. A right triangle is a triangle, in which one of the angles is 90 degrees. Pythagoras’s theorem says, for right triangle, the following formula holds:

Here, c is the length of the hypotenuse and a and b are the length of the other two sides. If a, b and c are all integers, then together they are called a Pythagorean triple.

In this problem, you will be given a Pythagorean triple, you will have to answer the length of the hypotenuse from the given triple.


The only input line contains three integers X, Y and Z ( 1 ≤ X,Y,Z ≤ 109 ), the three sides of a Pythagorean triangle.


The output contains one integer, the length of the hypotenuse of the given triangle.


3 4 5
5 12 13



93% Solution Ratio

oneoff.odDr9WEMmMEarliest, Nov '16

oneoff.5IO9Vq0HBrFastest, 0.0s

nishat19Lightest, 0 B

touhidurShortest, 36B


Login to submit