Problem F
Pythagorean Problem

Ivan wants to make some right triangles out of wooden dowels for an art project. However, the dowels can only be cut in integer lengths. Given the lengths of two dowels, help Ivan decide whether he should look for a third dowel to complete a right triangle, or if it is hopeless.
Input
The input consists of one line with two space-separated integers $a$ and $b$ ($1\leq a, b\leq 10^4$), the lengths of the two sides.
Output
Output the smallest positive integer $c$ such that $a$, $b$ and $c$ could be the lengths of the sides of a right triangle. If there is no such value of $c$, output Pythagoras is sad :(.
Sample Input 1 | Sample Output 1 |
---|---|
3 4 |
5 |
Sample Input 2 | Sample Output 2 |
---|---|
13 5 |
12 |
Sample Input 3 | Sample Output 3 |
---|---|
4 6 |
Pythagoras is sad :( |