Maximize area: For integer solutions the perimeter must be divisible by 4.
Minimize perimeter: For integer solutions the area must be 2*n^2. The area must be less than 50000.