A famous theorem of the mathematician Pierre de Fermat, proved after more than 300 years, states that, for any natural number , there is no natural solution (except for or ) to the equation For , by contrast, there are infinite non-trivial solutions. For instance, , , , ….
Write a program that, given four natural numbers with and , prints a natural solution to the equation such that and .
Input consists of four natural numbers such that and .
Print a line following the format of the examples, with a natural
solution to the equation
that fulfills
and
.
If there is more than one solution, print the one with the smallest
.
If there is a tie in
,
print the solution with the smallest
.
If there are no solutions, print “No solution!”.
Author: Unknown
Translator: Carlos Molina
Generation: 2026-01-25T10:29:07.862Z
© Jutge.org, 2006–2026.
https://jutge.org