UVa 10087 - The Tajmahal of ++Y2k

10087 - The Tajmahal of ++Y2k

 * http://acm.uva.es/p/v100/10087.html

Summary
Find magic squares with given magic constants.

Explanation
It is very hard to write a program to construct ALL magic squares, but since this problem only asks you to find ONE magic square, this is easy. Such methods are well-known. Check out these pages:

http://en.wikipedia.org/wiki/Magic_square

http://mathworld.wolfram.com/MagicSquare.html

Gotcha's
1. There are NO 2x2 magic squares. Beware!

2. You can have 0 or negative integers in your generated squares.

Input
3 15 3 10 3 9

Output
8         1          6         3          5          7         4          9          2

You can't be like Shahjahan!

6        -1          4         1          3          5         2          7          0