Fermat's last theorem (2) P18203


Statement
 

pdf   zip

thehtml

This is another exercise about Fermat’s last theorem. (See the exercise ‍.)



Write a program such that, given a sequence of lines, each one with four natural numbers a, b, c, d with ab and cd, prints the first natural solution to the equation

  x3 + y3 = z3

that fulfills the restrictions of a line: axb and cyd.

Input

Input has several lines, each one with four natural numbers a,b,c,d such that ab and cd.

Output

Print a line following the format of the examples, with a natural solution to the equation

  x3 + y3 = z3

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 x. If there is a tie in x, print the solution with the smallest y. If there are no lines with solution, print “No solution!”.

Public test cases
  • Input

    2 5 4 13
    

    Output

    No solution!
    
  • Input

    1 1 1 1
    0 1 0 1
    1 100 1 100
    

    Output

    0^3 + 0^3 = 0^3
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Translator
    Carlos Molina
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    C++ Java Python
    User solutions
    C C++ Python