Canadian Computing Competition: 2016 Stage 1, Junior #2
Magic Squares are square arrays of numbers that have the interesting property that the numbers in each column, and in each row, all add up to the same total.
Given a
Input Specification
The input consists of four lines, each line having 4 space-separated integers.
Output Specification
Output either magic
if the input is a magic square, or not magic
if the input is not a magic square.
Sample Input 1
Copy
16 3 2 13
5 10 11 8
9 6 7 12
4 15 14 1
Output for Sample Input 1
Copy
magic
Explanation for Output for Sample Input 1
Notice that each row adds up to
Sample Input 2
Copy
5 10 1 3
10 4 2 3
1 2 8 5
3 3 5 0
Output for Sample Input 2
Copy
not magic
Explanation for Output for Sample Input 2
Notice that the top row adds up to
Comments
Tip for anyone doing this in Java:
The magic square can be represented as a 2D array of size 4 x 4
THANKS
This problem is a great math concept.
This comment is hidden due to too much negative feedback. Show it anyway.
This comment is hidden due to too much negative feedback. Show it anyway.
This is one of the hardest J2's I have ever done.
It's actually not that hard if you write many lines.
Facts
test cases too weak just need to check rows
Since the original data were weak,
more test cases were added to prevent this solution, and all submissions were rejudged.
Everyone, if you are using java to solve this question,and having a wa because of "presentation",remember to use System.out.println instead of just print, the grader has some little problem because it is tesing all the case together, so if your out put don't move to the nxt line, what domj grader will see is something like"magicmagicnot magicmagic"
this must be the predecessor to what is probably the most controversial CCC problem of all time