Fermat’s last theorem (1)

A famous theorem of the mathematician Pierre de Fermat, proved after more than 300 years, states that, for any natural number n3n\ge 3, there is no natural solution (except for x=0x= 0 or y=0y= 0) to the equation xn+yn=zn.x^{n} + y^{n} = z^{n} . For n=2n= 2, by contrast, there are infinite non-trivial solutions. For instance, 32+42=523^2 + 4^2 = 5^2, 52+122=1325^2 + 12^2 = 13^2, 62+82=1026^2 + 8^2 = 10^2, ….

Write a program that, given four natural numbers a,b,c,da,b,c,d with aba\le b and cdc\le d, prints a natural solution to the equation x2+y2=z2x^2 + y^2 = z^2 such that axba\le x\le b and cydc\le y\le d.

Input

Input consists of four natural numbers a,b,c,da, b, c, d such that aba\le b and cdc\le d.

Output

Print a line following the format of the examples, with a natural solution to the equation x2+y2=z2x^2 + y^2 = z^2 that fulfills axba\le x\le b and cydc\le y\le d. If there is more than one solution, print the one with the smallest xx. If there is a tie in xx, print the solution with the smallest yy. If there are no solutions, print “No solution!”.

Problem information

Author: Unknown
Translator: Carlos Molina

Generation: 2026-01-25T10:29:07.862Z

© Jutge.org, 2006–2026.
https://jutge.org