UVa 10087
From Algorithmist
Contents |
[edit] 10087 - The Tajmahal of ++Y2k
[edit] Summary
Find magic squares with given magic constants.
[edit] 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
[edit] Gotcha's
1. There are NO 2x2 magic squares. Beware!
2. You can have 0 or negative integers in your generated squares.
[edit] Input
3 15 3 10 3 9
[edit] 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

