Fermat's last theorem (1) P36430


Statement
 

pdf   zip

thehtml

A famous theorem of the mathematician Pierre de Fermat, proved after more than 300 years, states that, for any natural number n≥ 3, there is no natural solution (except for x= 0 or y= 0) to the equation

  xn + yn = zn .

For n= 2, by contrast, there are infinite non-trivial solutions. For instance, 32 + 42 = 52, 52 + 122 = 132, 62 + 82 = 102, ….



Write a program that, given four natural numbers a,b,c,d with ab and cd, prints a natural solution to the equation

  x2 + y2 = z2

such that axb and cyd.

Input

Input consists of 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

  x2 + y2 = z2

that fulfills axb and cyd. If there is more than one solution, 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 solutions, print “No solution!”.

Public test cases
  • Input

    2 5 4 13
    

    Output

    3^2 + 4^2 = 5^2
    
  • Input

    1 1 1 1
    

    Output

    No solution!
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Translator
    Carlos Molina
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    C++ Java Python
    User solutions
    C C++ Java Python