.
Let x be the length of the longer leg, in centimeters.
Then the shorter leg length is (x-21) cm, while the hypotenuse length is (x+3) cm.
The Pythagorean theorem gives you an equation
x^2 + (x-21)^2 = (x+3)^2
Simplify and solve for x:
x^2 + x^2 - 42x + 441 = x^2 + 6x + 9
x^2 - 48x + 432 = 0
(x-12)*(x-36) = 0
The roots of the last equation are 12 and 36.
But only greater of the two roots, namely 36, is the solution to the problem,
since 12 becomes NEGATIVE, when 21 is subtracted from it.
ANSWER. The longer leg is 36 cm long.
CHECK. 36^2 + (36-21)^2 = 1521, and (36+3)^2 = 39^2 = 1521. ! Correct !