Fermat’s last theorem (3)

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 a≤ba\le b and c≤dc\le d, prints the number of solutions to the equation x2+y2=z2x^2 + y^2 = z^2 such that a≤x≤ba \le x \le b and c≤y≤dc \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 a≤ba\le b and c≤dc\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 a≤x≤ba \le x \le b and c≤y≤dc \le y \le d.

Problem information

Author: Unknown
Translator: Carlos Molina

Generation: 2026-01-25T11:52:56.039Z

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