Fermat’s last theorem (2)

This is another exercise about Fermat’s last theorem. (See the exercise problem://problemsjutge.org:problems/p1/roura/fermat-1.pbm.)

Write a program such that, given a sequence of lines, each one with four natural numbers a,b,c,da, b, c, d with a≤ba\le b and c≤dc\le d, prints the first natural solution to the equation x3+y3=z3x^3 + y^3 = z^3 that fulfills the restrictions of a line: a≤x≤ba\le x\le b and c≤y≤dc\le y\le d.

Input

Input has several lines, each one with four natural numbers a,b,c,da,b,c,d such that a≤ba\le b and c≤dc\le d.

Output

Print a line following the format of the examples, with a natural solution to the equation x3+y3=z3x^3 + y^3 = z^3 that fulfills the restrictions of a line. If there are two or more lines with solution, print the first found. If there are several solutions for the same line, 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 lines with solution, print “No solution!”.

Problem information

Author: Unknown
Translator: Carlos Molina

Generation: 2026-01-25T10:20:13.238Z

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