Fermat's last theorem (3) P90697


Statement
 

pdf   zip

This is another exercise about Fermat’s last theorem, which was explained in the exercise problem://problemsjutge.org:problems/p1/roura/fermat-1.pbm

Write a program that, given four natural numbers a,b,c,da,b,c,d with aba\le b and cdc\le d, prints the number of solutions 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 has several cases. Each case consists of four natural numbers a,b,c,da, b, c, d such that aba\le b and cdc\le d.

Output

For every case, print in a line the number of solutions to the equation x2+y2=z2x^2 + y^2 = z^2 that fulfill axba \le x \le b and cydc \le y \le d.

Public test cases
  • Input

    2 5 4 13
    1 1 2 3
    

    Output

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