Congruent Numbers

From programming_contest
Revision as of 22:30, 29 December 2017 by imported>Kmk21 (Created page with "This problem gives us two edges of a right triangle, and asks whether the area is integral and the hypotenuse rational The only difficulty here is we have to use rational mat...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This problem gives us two edges of a right triangle, and asks whether the area is integral and the hypotenuse rational

The only difficulty here is we have to use rational math. If we use floats, then we may have an answer which is CLOSE to an integer, but not really.

Checking for area integrality is trivial. Simply perform the calculation and check whether the denominator divides the numerator evenly.

Checking the hypotenuse for rationality involves performing the pythagorean theorem, and then checking whether both the numerator and denominator in reduced form are perfect squares.