Congruent Numbers: Difference between revisions

From programming_contest
Jump to navigation Jump to search
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..."
 
(No difference)

Latest revision as of 22:30, 29 December 2017

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.